Image looks different after removing transparent space and scaled

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
snibgo
Posts: 12159
Joined: 2010-01-24T06:01:33+00:00
Authentication code: 1151
Location: England, UK

Re: Image looks different after removing transparent space and scaled

Post by snibgo »

niyanwen wrote: I am new to image processing, could you recommend what's the right way to view it? like by which software?
There is no "right" way. Images with transparency are always shown flattened against some background. A chequerboard background is traditional because it clearly shows which areas of the image are entirely transparent. But it creates viewing problems when the image has areas that are only slightly transparent.

In Gimp, Edit | Preferences | Display can change transparency from checks to solid white, gray or black. Or Image |Flatten image will remove transparency.

Gimp's Color Picker can show RGBA values for individual pixels. This clearly shows that your images have areas of constant colour (RGB channels) but varying transparency (alpha channel).

Personally, I mostly use Microsoft Photo Viewer, and my own unpublished image editor. But Gimp can do the job.
snibgo's IM pages: im.snibgo.com
niyanwen
Posts: 71
Joined: 2019-05-23T23:19:12+00:00
Authentication code: 1152

Re: Image looks different after removing transparent space and scaled

Post by niyanwen »

Hi,

this is my scale command, I scale it first then trim the transparency on the border
convert a.png -resize 4500x5400! b.png

PNG version is related to ImageMagick version or not? since I work for industry, current image magick version is the widely used version our company
niyanwen
Posts: 71
Joined: 2019-05-23T23:19:12+00:00
Authentication code: 1152

Re: Image looks different after removing transparent space and scaled

Post by niyanwen »

@snibgo

yeah looks like alpha channel value is different after image magick processed, because of this difference could we consider it as different?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-03T00:14:51+00:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Image looks different after removing transparent space and scaled

Post by fmw42 »

I cannot see any visual difference when I use

Code: Select all

convert img.png -resize 4500x5400! img_scale6.png
magick img.png -resize 4500x5400! img_scale7.png
Between these two nor between either and the original

IM 6.9.10.67 and 7.0.8.67 Mac OSX with libpng 1.6.36

Use

Code: Select all

convert -list format
to check which version of libpng.

Use

Code: Select all

convert -version
for your ImageMagick version and date.

If on IM 7 change convert to magick
niyanwen
Posts: 71
Joined: 2019-05-23T23:19:12+00:00
Authentication code: 1152

Re: Image looks different after removing transparent space and scaled

Post by niyanwen »

when I run convert -list format, I got
PNG* rw- Portable Network Graphics (libpng 1.6.28)
See http://www.libpng.org/ for details about the PNG format.
PNG00* rw- PNG inheriting bit-depth, color-type from original if possible
PNG24* rw- opaque or binary transparent 24-bit RGB (zlib 1.2.11)
PNG32* rw- opaque or transparent 32-bit RGBA
PNG48* rw- opaque or binary transparent 48-bit RGB
PNG64* rw- opaque or transparent 64-bit RGBA
PNG8* rw- 8-bit indexed with optional binary transparency

when I run convert -version, this is what I got
Version: ImageMagick 6.9.4-1 Q16 x86_64 2019-09-29 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2016 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC OpenMP
Delegates (built-in): bzlib freetype jng jpeg png tiff xml zlib

so you mean i might need to upgrade image magick version or libpng version?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-03T00:14:51+00:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Image looks different after removing transparent space and scaled

Post by fmw42 »

Your Imagemagick is ancient by version number, though currently patched supposedly on 9/29/2019. So just a couple of weeks ago. But Linux distributions often only patch for security. So it is possible there is a bug or a missing update. But I would start with upgrading your libpng, if you can. The version I used is 1.6.36 and yours is 1.6.28. So your version is 8 releases old. See if your Hosting provider can simply upgrade libpng.

Your list of delegates is missing lcms. That is needed for good color control. So perhaps that could be an issue. Have your hosting provider install that into ImageMagick as well. See http://www.littlecms.com and https://imagemagick.org/download/delegates/
niyanwen
Posts: 71
Joined: 2019-05-23T23:19:12+00:00
Authentication code: 1152

Re: Image looks different after removing transparent space and scaled

Post by niyanwen »

Since this version 6.xxx is widely used in our company and is recommended, I would not like to change until it is needed
niyanwen
Posts: 71
Joined: 2019-05-23T23:19:12+00:00
Authentication code: 1152

Re: Image looks different after removing transparent space and scaled

Post by niyanwen »

so my question is there is no way to modify the command to fix this right?
the only way to fix it is update my image magick version?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-03T00:14:51+00:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Image looks different after removing transparent space and scaled

Post by fmw42 »

Did you try upgrading libpng? Did you try installing lcms?

This is my command and result:

Code: Select all

convert b07s8dt2vc-large-front_image.png -resize 3500x3500^ b07s8dt2vc-large-front_image_resize.png
http://www.fmwconcepts.com/misc_tests/b ... resize.png

If this looks correct, then try what I suggest above.
snibgo
Posts: 12159
Joined: 2010-01-24T06:01:33+00:00
Authentication code: 1151
Location: England, UK

Re: Image looks different after removing transparent space and scaled

Post by snibgo »

niyanwen wrote:so my question is there is no way to modify the command to fix this right?
the only way to fix it is update my image magick version?
What exactly needs fixing? Please link to input/output images that you think are wrong, with the command you used.

The images you have linked don't use profiles, so I doubt that LCMS will make any difference.
snibgo's IM pages: im.snibgo.com
niyanwen
Posts: 71
Joined: 2019-05-23T23:19:12+00:00
Authentication code: 1152

Re: Image looks different after removing transparent space and scaled

Post by niyanwen »

Hi, @snibog
so the thing is in some certain place the alpha channel value is different, the original image has some transparency
snibgo
Posts: 12159
Joined: 2010-01-24T06:01:33+00:00
Authentication code: 1151
Location: England, UK

Re: Image looks different after removing transparent space and scaled

Post by snibgo »

Please link to input/output images that you think are wrong, with the command you used.
snibgo's IM pages: im.snibgo.com
niyanwen
Posts: 71
Joined: 2019-05-23T23:19:12+00:00
Authentication code: 1152

Re: Image looks different after removing transparent space and scaled

Post by niyanwen »

original image: https://drive.google.com/open?id=1ufx2A ... XZMolPcnf1
output image: https://drive.google.com/open?id=122q_p ... mGJcV0XuFz

convert img.png -resize 4500x5400! img_scale6.png
convert shirt.png -trim +repage -bordercolor none -border 5 shirt3.png
niyanwen
Posts: 71
Joined: 2019-05-23T23:19:12+00:00
Authentication code: 1152

Re: Image looks different after removing transparent space and scaled

Post by niyanwen »

snibgo
Posts: 12159
Joined: 2010-01-24T06:01:33+00:00
Authentication code: 1151
Location: England, UK

Re: Image looks different after removing transparent space and scaled

Post by snibgo »

Which of those two commands did you use to make that output from that input?
snibgo's IM pages: im.snibgo.com
Post Reply