Imagemagick is increasing filesize on ezpublish 4.7 enterprise - imagemagick

I am using imagemagic on eZpublish with image.ini.append.php. The quality is set to 100. But the image file size(jpg) is increasing(almost double) after the conversion, even if the resolution is same as the original image in the converted one.
Is there any way to keep the filesize same or smaller by keeping the quality intact?
My Settings in the image.ini.append.php:
[ImageMagick]
IsEnabled=true
Filters[]=cropfromcenter=-gravity center -crop %1x%2+0+0 +repage
Filters[]=cropfromtop=-gravity north -crop %1x%2+0+0 +repage
Filters[]=thumbnail=-resize x%4 -resize %3x< -resize 50% -gravity center -crop %1x%2+0+0 +repage
[MIMETypeSettings]
Quality[]
Quality[]=image/jpeg;100
[reference]
HideFromRelations=enabled
Filters[]
Filters[]=geometry/scalewidthdownonly=1600
[custom_1200]
GUIName=1200px
Reference=reference
Filters[]
Filters[]=geometry/scalewidthdownonly=1200

Related

how to imagemagick crop only width

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

Imagemagick create image and place image inside with max size

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

Batch crop image having variable height

I want to batch crop images having variable height. I have fixed width, x and y coordinates value but not the height value. I tried the code mentioned below but it didn't work. Only top, left and right side needs to be cropped.
mogrify -crop 320xauto+864+323 +repage image.png
Use -chop instead of -crop:
mogrify -chop 864x0 +repage image.png
mogrify -chop 0x323 +repage image.png
mogrify -gravity East -chop 333x0 +repage image.png

Use ImageMagick to resize and then crop an image from command line

I have a jpg image which I want to resize as follows:
Keeping the aspect-ratio of the image same, resize it to as close as 640x360 as possible, without keeping any portion of the new image "blank"/"empty". That is, it's okay if after resizing, it becomes 800x360 or 640x420, but not okay if it is 400x360 (because 400 is lesser than 640) or 640x200 (because 200 is lesser than 360).
After this, I need to center-crop the above-resized image to the ratio of 16:9.
What would be the easiest set of shell commands which can be used to achieve this using imagemagick?
I tried both
convert 'orig_image.jpg' -resize 640x360 -gravity Center -crop 640x360+0+0 'changed_image.jpg' and
convert 'orig_image.jpg' -resize 640x360 -gravity Center -crop 640x360+0+0 +repage 'changed_image.jpg'
but none worked. -resize 640x360 is resizing the image, but not fulfilling my above requirement. That is, 2448x3264 is resizing to 270x360 instead of 640x480
Perhaps you can use this:
convert orig.jpg \
-resize 640x360^ \
-gravity Center \
-extent 640x360
changed.jpg
Where -resize 64x360^ preserves the minimum aspect ratio, and -extent 640x360 (without +0+0) respected -gravity Center

Cutting x pixels from an image

Why this is creating many images instead of just two?
convert input-image.jpg -crop 28x +repage monet_vertical_%d.jpg
I want to get two images; 28 pixels from the base and another image with what's left.
convert $f -gravity South -crop 0x28+0+0 +repage label.jpg
convert $f -gravity South -chop 0x28 not-labeled.jpg

Resources