I am trying to crop and swap different parts of a big 800x800 image and re-create 800x800 image using imagemagick with this command.
magick mogrify titli.gif -crop 2x4# +repage -reverse -append -path converted titli.gif
my problem is "-append" creates tall image (400x1600) & "+append" creates wide image (3200x200)
How can I get a large image of original size 800x800 but with cropped and swapped (reversed) parts set in "mosaic or tiled" style...
If I understand the question, you shouldn't need "mogrify" to do that. Just "magick" should accomplish that task.
It looks like you'll have to crop the image into 8 pieces, reverse them, and "-append" them vertically as you've done.
Then after that, and in the same command, you'll need to crop that result in half vertically and "+append" those two pieces horizontally to get the 800x800 output.
This example command shows how it works...
magick in.png -crop 2x4# -reverse -append -crop 1x2# +append out.png
If you're doing any more operations within the same command you'll probably want to use "+repage" after the "+append" to reset the image geometry back to WxH+0+0.
Related
I have two files;
1.jpg = 14000x2800 pixels
2.jpg = 2800x128 pixels
I use the following command:
...\convert.exe -auto-orient -quality 100 -append "1.jpg" "2.jpg" "out.jpg"
The goal is to merge the images together on the vertical axis, and it works great but now I need to add a straight horizontal black line between images (line's length should be the biggest file's length, meaning from left to right) while appending.
Is there any way to do that without a second command?
Easier description with MSPaint skills
Here's a way to do it:
magick 1.jpg 2.jpg -size "%[fx:u.w>v.w?u.w:v.w]x10" xc:black -swap 2,1 -append result.png
That says... load 1.jpg and 2.jpg. Define the width for the canvas we create next as "whatever is the wider of 1.jpg (referred to as u) and 2.jpg (referred to as v)" by 10 pixels tall. Create a black canvas that size. Now swap the order so that the canvas we just created is between the two images. Append all 3 images and save.
That gives you one of these, depending which one you load first:
If you want the unfilled, white background area beside the narrower image to be, say magenta, use:
magick -background magenta 1.jpg 2.jpg -size "%[fx:u.w>v.w?u.w:v.w]x10" xc:black -swap 2,1 -append result.png
Keywords: ImageMagick, image processing, wider, widest, taller, tallest, match existing image width, match height.
I am trying to use ImageMagick to place one image (Poseidon_map01.jpg in my code below) in the top-left corner of another (zzOcean Backdrop.png) then crop the resulting image down to 1280x720.
This is the command I currently have:
".\ImageMagick-7.0.8-12-portable-Q16-x64\magick.exe" ".\Raw\zzOcean Backdrop.png" ".\Raw\Poseidon_map01.jpg" -gravity northwest -composite -crop 1280x720>! +repage ".\1280x720\Poseidon_map01.jpg"
The problem is that this command is cutting the composited image into 1280x720 pieces then saving all of those pieces with the names Poseidon_map01-1.jpg to Poseidon_map01-48.jpg. Poseidon_map01-1.jpg is the top-left corner of the composited image and this is the piece that I want to keep. I want to discard the rest of the composite. Does anyone know what I have to change in my command to make this happen? Thanks.
In Imagemagick crop, if you do not include the +X+Y offsets, it will crop as many pieces as it can given the size you specify. That is called tiled cropping. So use -crop WxH+X+Y>!
See https://imagemagick.org/Usage/crop/#crop
".\ImageMagick-7.0.8-12-portable-Q16-x64\magick.exe" ".\Raw\zzOcean Backdrop.png" ".\Raw\Poseidon_map01.jpg" -gravity northwest -composite -crop 1280x720+0+0>! +repage ".\1280x720\Poseidon_map01.jpg"
I am not a windows user and syntax may vary some. You may need to escape the > or ! with ^ on windows or put double quotes around the whole crop set of arguments. Keep that in mind, if this does not work. See https://imagemagick.org/Usage/windows/
I'm trying to crop an image into a bunch of 256x256 tiles (with the right-most and bottom-most images less than 256 pixels due to the remainders), but ImageMagick always generates images that are 1x1.
I use this command (Windows 7 command prompt):
convert WBS.png -crop 256x256 +repage +adjoin output\WBS_%02d.jpg
After cropping the following message is displayed:
convert: geometry does not contain image `WBS.png' # warning/transform.c/CropImage/589.
After cropping, the output folder contains 1634 jpg files, all of which are 1 x 1 pixel. The source image is 7218x7650.
Suggestions? I'm sure I'm making some blatant mistake, but I don't know what it is.
This can happen if the origin of the image is not at 0,0. In that case, using +repage before processing the image should do the trick, i.e.
convert WBS.png +repage -crop 256x256 +repage +adjoin output\WBS_%02d.jpg
See also the documentation of the -crop option.
I am using mogrify utility to batch converting images and preparing them for web.
Bumped with a question how to do watermark using same mogrify utility. There are a lot of examples with how to watermark but all of them using composite utility. It is not suitable for me as I dont want to split process into two steps.
Here is a simplified command line
mogrify -resize 400x400 -tile WATERMARK_FILE.png -path out\ input.jpg
it is do resize but does not compose with watermark
UPDATE:
Unfortunately its inpossible to do it by single step (via morgify). Although morgify accepts the -tile parameter it result to nothing. Probably its is a bug, because image to tile is read from disk but not used.
I solved the task by separately preparing watermark tiled image by size equalent or bigger then destination images.
:: prepare emty transparent image with size %IMG_SIZE%
convert -size %IMG_SIZE% xc:none "%WATERMARK_BASE_FILE%"
:: tile watermark on it
composite -dissolve 30 -tile "%WATERMARK_FILE%" "%WATERMARK_BASE_FILE%" "%WATERMARK_TILED_FILE%"
:: resize images and draw watermark on each image
morgify -resize %IMG_SIZE% -gravity center -draw "image src-over 0,0 0,0 '%WATERMARK_FILE%'" -path "%DST_DIR%" "%SRC_MASK%"
I have five images of sizes: 600x30, 600x30, 600x30, 600x30, 810x30. Their names are: 0.png, 1.png, 2.png, 3.png, 4.png, respectively.
How do I merge them Horizontally to make an image of size 3210x30 with ImageMagick?
ImageMagick ships with the montage utility. Montage will append each image side-by-side allowing you to adjust spacing between each image (-geometry), and the general layout (-tile).
montage [0-4].png -tile 5x1 -geometry +0+0 out.png
Other examples can be found on Montage Usage page
ImageMagick has command line tool named 'convert' to merge images horizontally, or for other purpose. i have tried this command and working perfectly on your case:
To join images horizontally:
convert +append *.png out.png
To stack images vertically:
convert -append *.png out.png
Use -resize if the images don't have the same width/height
You can fix the height for all of them with the -resize option, e.g. to fix a 500 pixel height on two images joined horizontally:
convert +append image_1.png image_2.png -resize x500 new_image_conbined.png
Or for vertical joins, you would want to set a fixed width instead:
convert -append image_1.png image_2.png -resize 500x new_image_conbined.png
Example:
image_1.png 1067x600
image_2.png 1920x1080
new_image_conbined.png 889x500
Related:
https://askubuntu.com/questions/226054/how-do-i-join-two-images-together
https://superuser.com/questions/290656/combine-multiple-images-using-imagemagick
How to do it interactively with GIMP
If you need to crop/resize images interactively first, which is often the case, then GIMP is the perfect tool for it, here's a detailed step-by-step: https://graphicdesign.stackexchange.com/questions/83446/gimp-how-to-combine-two-images-side-by-side/145543#145543
SVGs
ImageMagick 6.9.11-60 doesn't handle them, so see:
How to concatenate SVG files lengthwise from linux command line?
https://graphicdesign.stackexchange.com/questions/137096/is-there-a-way-to-stack-two-svgs-on-top-of-each-other
https://graphicdesign.stackexchange.com/questions/90844/joining-together-multiple-svg-images
Very simple with ImageMagick (brew install imagemagick )
convert +append image_1.png image_2.png new_image_conbined.png
Anyone using the MiniMagick rails gem can use the built-in tool to merge images:
# Replace this with the path to the images you want to combine
images = [
"image1.jpg",
"image2.jpg"
]
processed_image = MiniMagick::Tool::Montage.new do |image|
image.geometry "x700+0+0"
image.tile "#{images.size}x1"
images.each {|i| image << i}
image << "output.jpg"
end
Check out the documentation for #geometry options to handle resizing and placement. The current example will resize images to a 700px height while maintaining the image's aspect ratio. +0+0 will place the image with no gaps between them.
The convert +append method described in other answers appends images horizontally, aligned to the top. If you prefer to align to the bottom or center, try:
convert input1.png input2.png -gravity South +append output.png
or
convert input1.png input2.png -gravity Center +append output.png
Source: Fred's ImageMagick Tidbits http://www.fmwconcepts.com/imagemagick/tidbits/image.php#append