imagick resizing to wrong height - imagick

I have a 3200x1200 png image
I am trying to resize it to 200x200
I have tried multiple different ways, but it always resizes to a height of 75
convert -scale 200x200 s.png s.jpg
convert -resize 200x200 s.png s.jpg
convert -geometry 200x200 s.png s.jpg
convert s.png -sample 200x200 s.jpg
the width of the resized image is correct, but no matter what I do, the height is 75px.
why does this happen?

convert -resize 200x200\! s.png s.jpg
found here: http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=16724

Related

How to use convert -crop to add more background to animated gif/enlarge image?

I'm trying to crop an animated gif usind convert -crop. In some cases it's necessary to add more background to the image to fit. With other image formats it's done with
convert original.gif -rotate 0 -crop 1519x759-237-61\! -background white -flatten edited.gif
For gifs I tried
convert original.gif -coalesce -rotate 0 -crop 1519x759-237-61\! +repage edited.gif
convert is clipping/trimming the background and just the "subject" of the image is shown.
Example is here: https://imgur.com/ls1ED0Z
Result is here: https://imgur.com/59678cD
Expected Result is https://imgur.com/vZGaD7r
I added the red border to show how big the image is. Someone with a great solution? :)
Jan
To do what you want in Imagemagick, you should be using -extent rather than -crop in order to extend the size of the output.
Try this. Adjust the size and offset and background color as desired.
convert original.gif -coalesce -rotate 0 +repage -background white -extent 1519x759-237-61! -bordercolor red -border 3 result.gif
I have added a red border around the image.
With IM you can choose to "-crop", which is most often used to reduce the viewport dimensions, or "-extent", which can also be used to enlarge the viewport. It looks like there are a couple other issues with achieving the result in your sample image, but for starters, try simply substituting your "-crop" with "-extent" like this...
convert original.gif -coalesce -rotate 0 -extent 1519x759-237-61 +repage edited.gif
That will put your input image in a viewport of 1519x759, and place its upper left corner at 237 pixels from the left and 61 pixels from the top. You shouldn't need the exclamation point "!" in any case.

Resize with ImageMagick with a maximal width / height

The command
imageconvert.exe in.jpg -resize 800x600 out.jpg
resizes the image so that it keeps original ratio, with maximum width of 800, and maximum height of 600 pixels. But if the image is smaller both in width and height (e.g. a 300x200 image), it will be enlarged to reach 800 or 600, and I don't want this.
How to keep the same kind of resizing (when width > 800 or height > 600), but such that an image that is smaller both in width and height (e.g. a 300x200 image), will be untouched?
I think you need the > flag on the resize. Let's create some images (one red 300x200, another blue 1000x500):
convert -size 300x200 xc:red small.png
convert -size 1000x500 xc:blue large.png
Now convert them both to 800x600 with no flags:
convert small.png -resize 800x600 a.png # 800x533
convert large.png -resize 800x600 b.png # 800x400
Now with flags:
convert small.png -resize 800x600\> a.png # 300x200
convert large.png -resize 800x600\> b.png # 800x400
You may need a caret (^) rather than a backslash on Windows.
The various flags are explained in the documentation here. Thanks to #user1133275 for the suggestion.

ImageMagick: Resize image (rectangle to square); keep aspect ratio of main object

I have portrait and landscape JPEG images.
I want to make square thumbnails with white background from all of them. I need to keep the aspect ratio of all images and reduce the larger border to 200px.
I want to use ImageMagick (CLI) but I don't know how to do that. Any idea ?
Here is the individual images :
I think you need this:
convert -background white -gravity center \
input.jpg -resize 200x200 -extent 200x200 result.jpg

Resize without whitespace surrounding on images using graphicsmagick or imagemagick

I'm using graphicsmagick to resize an image to a thumbnail, but it's adding a white surrounding border padding.
The command I'm using is:
gm convert matrix.jpg -resize "80x80>" -gravity center -extent 80x80 thumbnail.jpeg
As you can see, there is some white padding around the image, but I don't want this. Ideally I'd like (the entire image not just a crop of it) to fill the desired 80x80 output size.
How can this be achieved in either imagemagick or graphicsmagick?
I used ImageMagick with this image. This solution requires to know the size of the input image.
Input
The image has 145 pixels horizontally and 200 pixels vertically.
Crop
Crop from the top of the image:
convert -crop 145x145+0+0 -resize 80x80 matrix.jpg thumbnail.jpeg
I used 145x145 in order to extract a square from the original image. +0+0 is the offset of the extracted square, hereby the top left.
Crop with the center of the image:
convert -crop 145x145+0+27 -resize 80x80 matrix.jpg thumbnail.jpeg
The vertical offset is set to 27 because we have to remove 55 (200 - 145) pixels on top or bottom, so we need to remove 27 (55 รท 2) pixels on the top and 28 pixels on the bottom.
Crop with the bottom of the image:
convert -crop 145x145+0+55 -resize 80x80 matrix.jpg thumbnail.jpeg
Resizing without crop
convert -resize 80x80\! matrix.jpg thumbnail.jpeg
The ! flag (escaped with \! as suggested in the documentation) after the resize parameters forces ImageMagick to ignore the aspect ratio.
If you want to keep the original aspect ratio, without image distortion, you can use the ImageMagick -trim option to get rid of the white padding:
convert "matrix.jpg" -resize "80x80" -gravity center -extent 80x80
-trim "thumbnail.jpg"
This will produce a 58x80 uncropped image with the same aspect ratio as the original. It is 58x80 because ImageMagick uses the larger dimension of the original to compute the scale factor (in this case 80/200) and scales the smaller dimension by that same factor to preserve aspect ratio.
If you want an uncropped image of exactly 80x80 pixels, this is a different aspect ratio than the original. The output image will have distortion, and #AL's resizing without crop option will work.
convert "matrix.jpg" -resize "80x80!" -gravity center -extent 80x80
"thumbnail.jpg"
Tested in Windows 7 with ImageMagick 6.8.9. #AL syntax is probably Linux.

How to convert image into less pixelate with ImageMagic

I want to convert image in less pixelate with ImageMagic and I give a try with
convert -resize 20x20 -flop -gaussian-blur 1x5 -scale 100% -scale 500% -colorspace gray -quantize sRGB +dither /png.png /sam_pic.png
And its looking like the following image:
But I want to Increase pixel size that is Image with less pixel
Please suggest me how to do it and modify command.
I got the solution.
Only change the size and increase the scale
convert -resize 18x18 -flop -gaussian-blur 1x5 -scale 110% -scale 500% -colorspace gray /png.png /sam_pic.png

Resources