Imagick trimImage function issue

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
Post Reply
mjamal
Posts: 31
Joined: 2017-12-27T06:13:59-07:00
Authentication code: 1152

Imagick trimImage function issue

Post by mjamal » 2018-09-10T03:23:44-07:00

Hello Team,

Can any one please let me know how I am getting the two different image mode for the trim output of an image.

Like I am checking the below command on my two different servers which are having different image magick versions installed.

Server 1: Version "ImageMagick 6.7.8-9" is installed and when I am executing the below command then the output image mode in photoshop is showing "RGB" and which is correct because my input image mode is also in "RGB".

Server 2: Version "ImageMagick 6.9.4-10" is installed and when I am executing the below command then the output image mode in photoshop is showing "Grayscale" and which is I think incorrect because my input image mode is in "RGB".

COMMAND:
exec("convert iuputImg.jpg -fuzz 1% -trim +repage outputImg.jpg");

Please any one let me know what exactly I am doing wrong or what need to be added in mentioned command. Also I used the PHP "trimImage " function and same issue faced with this also.
Let me know if anyone need the input image for checking.

Thanks in advanced

snibgo
Posts: 10544
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Imagick trimImage function issue

Post by snibgo » 2018-09-10T03:42:25-07:00

mjamal wrote:Let me know if anyone need the input image for checking.
Yes, we do. Otherwise we can only guess.

My guess is that the trimmed image contains no colour, all the pixels are some shade of gray. Some versions of IM will realise this, and save the image in the most efficient way.
snibgo's IM pages: im.snibgo.com

mjamal
Posts: 31
Joined: 2017-12-27T06:13:59-07:00
Authentication code: 1152

Re: Imagick trimImage function issue

Post by mjamal » 2018-09-10T04:36:12-07:00

Hello Snibgo,

Here is the input image which I am using for testing in both of my servers. Also yes the input image is having gray shades but in both of my servers the image mode is showing different.

INPUT IMAGE:
Firstlayerfile_final_0.jpg
Firstlayerfile_final_0.jpg (133.06 KiB) Viewed 156 times

snibgo
Posts: 10544
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Imagick trimImage function issue

Post by snibgo » 2018-09-10T04:43:33-07:00

So my guess was correct, and IM saves the image in the most space-saving mode. "-type truecolor" will force RGB mode, ie the output will contain colour channels.
snibgo's IM pages: im.snibgo.com

mjamal
Posts: 31
Joined: 2017-12-27T06:13:59-07:00
Authentication code: 1152

Re: Imagick trimImage function issue

Post by mjamal » 2018-09-11T02:08:25-07:00

@ Snibgo, Yes from "-type truecolor", I am now able to get the image mode in RGB. Thank you.

Post Reply