I'm trying to convert an image from landscape to portrait orientation with the command below:
convert sample_img.jpg -resize 1670x760 -gravity Center -background white -interlace plane -extent 1670x2288 vertical_img.jpg
Unfortunately both -gravity Center and -gravity South are not suitable for the result that I would like to achieve, is it possible to specify the height in pixel?
I found the splice option, using it I was able to obtain an image as desired with:
convert sample_img.jpg -resize 1670x760 -extent 1670x1188 -gravity north -splice 0x1100 vertical_img.jpg
Related
im trying to crop an image of size 1920x125058 into 900x125058 from the center
so I used magick convert in.png -crop 900x+510+0 out.png but this outputs a file of size 900x28800. shouldn't the height be untouched if it is not mentioned?
In Imagemagick 7, use magick, not magick convert. For center cropping, use -gravity center
magick in.png -gravity center -crop 900x125058+0+0 +repage out.png
I have trimmed .pngs and need them placed on a canvas (3000x3000 px) BUT with a max size.
convert -size 3000x30000 xc:transparent test.png -gravity south -composite -size 2200x2200 result.png
The code I have now works, but the sizing of the image is off. My canvas is 3000x3000px as intended, but the image placed on the canvas doesn't have the correct size. It should have a max width/height of 2200px and if possible be scaled up, if they are to small in height.
This ImageMagick command will resize the input image to 2200 pixels on the longer side while maintaining its aspect, then create a 3000x3000 transparent canvas, then swap the input image and the canvas, and finish by compositing the resized input image onto the transparent canvas...
convert input.png -resize 2200x2200 \
-size 3000x3000 xc:none +swap -gravity south -composite result.png
For Windows change that continued line backslash "\" to a caret "^". For ImageMagick v7 use "magick" instead of "convert".
Unix syntax:
convert -size 3000x30000 xc:transparent \( test.png -resize 2200x2200 \) -gravity south -composite result.png
Windows syntax:
convert -size 3000x30000 xc:transparent ( test.png -resize 2200x2200 ) -gravity south -composite result.png
Why not use -extent?
convert input.jpg -resize 2200x2200 -background none -gravity south -extent 3000x3000 result.png
I would like to take this logo and place it on a black background.
I am using the below script
convert -size 4000x4000 canvas:#000000 -background \#000000 background.jpg
composite rev.jpg -gravity center background.jpg output.jpg
open output.jpg
Which generates. As you can see the colours have changed and I cannot work out why?
Just set the colorspace.
composite 03wp2.jpg -colorspace srgb -gravity center background.jpg output.jpg
Possibly a colour profile or are you using CMYK for the rev.jpg?
Try this which will shorten your code:
convert rev.jpg -background black -gravity center -extent 4000x4000 output.jpg
I would like to take a picture, resize it to 50% and put it on a black layer...
My issue is that resizing the image, resize the whole image (with the black layer too)and put it at the center of the new layer...
here's my code:
'convert -size 1920x1080 xc:Black -gravity center image.png -resize 20% -composite -flatten result.png'
how could I do to just resize the image.png and not the whole layer ?
thanks in advance
g.
I think you probably want this:
convert image.png -resize 50% -gravity center -background black -extent 1920x1080 result.png
Or this, which is another way of doing the same thing:
convert -size 1920x1080 xc:black \( image.png -resize 50% \) -gravity center -composite result.png
Or, a more succinct version:
convert xc:black[1920x1080\!] \( image.png -resize 50% \) -gravity center -composite result.png
The first one resizes your image and then extends it with black from the centre outwards to your desired size.
The second creates the correctly sized canvas, then loads your image and resizes it "on-the-side" in parentheses and composites the result onto the canvas.
Good morning,
I'd like to center and resize multiple images in a folder with different aspect ratios and keep the filename. The following is nearly what I like to have (it works perfect for the particular picture), but there I have to name every specific pic.
convert -size 100x100 xc:black -gravity center originalpic.jpg -thumbnail 300x300 -composite newpic.jpg
I tried to work with * to keep the original file name and to process every file in the folder but without success. Does anybody know how to do that?
Thank you!
Use the mogrify command to work with multiple files.
mogrify -size 100x100 xc:black -gravity center -thumbnail 300x300 -composite *.jpg
Another way would be to iterate over the images in bash and use the same name as output to overwrite:
for f in *.jpg
do convert -size 100x100 xc:black -gravity center $f -thumbnail 300x300 -composite $f
done
I think I got it for me in general:
First size down to the height you want, e.g. to 364px:
mogrify -resize x364 *.jpg
And then, e.g. you want to get a dimension of 546x364px, this:
mogrify -extent 546x364 -gravity center *.jpg
But at image with original size of 512x768 background is getting filled with white color, so I tried
mogrify -extent 546x364 -gravity center -background black *.jpg
and
mogrify -extent 546x364 -gravity center -fill black *.jpg
but background is still white :-(