PNG size become bigger when after thumbnail the png

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
needkane
Posts: 47
Joined: 2014-09-11T02:19:30-07:00
Authentication code: 6789

PNG size become bigger when after thumbnail the png

Post by needkane »

Hi:
Recently ,more and more png image size become bigger when after thumbnail.
Image:http://s3-us-west-2.amazonaws.com/qiniu-bs/bigger.png ( 720x300,57kb)

http://s3-us-west-2.amazonaws.com/qiniu-bs/bigger2.png (681x337,97.1kb)


Command:
convert bigger.png -thumbnail 600x +repage result.png

We find the result.png width and height both less than original, but the image's size both bigger than original.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: PNG size become bigger when after thumbnail the png

Post by snibgo »

What version of IM are you using?

With v6.9.0-0 I get:

Code: Select all

f:\web\im>%IM%identify bigger.png
bigger.png PNG 720x300 720x300+0+0 8-bit sRGB 256c 56.5KB 0.000u 0:00.000

f:\web\im>%IM%convert bigger.png -thumbnail 600x b.png

f:\web\im>%IM%identify b.png
b.png PNG 600x250 600x250+0+0 8-bit sRGB 124KB 0.000u 0:00.000
The width has shrunk to 600 pixels, as required. The size has more than doubled. We can see why: the "256c" label has gone. The input had only 256 colours, but interpolated resizing has increased the number of colours, so the output isn't palleted. I can cure this:

Code: Select all

f:\web\im>%IM%convert bigger.png -thumbnail 600x -colors 255 -type Palette b.png

f:\web\im>%IM%identify b.png
b.png PNG 600x250 600x250+0+0 8-bit sRGB 253c 53.1KB 0.000u 0:00.000
snibgo's IM pages: im.snibgo.com
needkane
Posts: 47
Joined: 2014-09-11T02:19:30-07:00
Authentication code: 6789

Re: PNG size become bigger when after thumbnail the png

Post by needkane »

snibgo wrote:What version of IM are you using?

With v6.9.0-0 I get:

Code: Select all

f:\web\im>%IM%identify bigger.png
bigger.png PNG 720x300 720x300+0+0 8-bit sRGB 256c 56.5KB 0.000u 0:00.000

f:\web\im>%IM%convert bigger.png -thumbnail 600x b.png

f:\web\im>%IM%identify b.png
b.png PNG 600x250 600x250+0+0 8-bit sRGB 124KB 0.000u 0:00.000
The width has shrunk to 600 pixels, as required. The size has more than doubled. We can see why: the "256c" label has gone. The input had only 256 colours, but interpolated resizing has increased the number of colours, so the output isn't palleted. I can cure this:

Code: Select all

f:\web\im>%IM%convert bigger.png -thumbnail 600x -colors 255 -type Palette b.png

f:\web\im>%IM%identify b.png
b.png PNG 600x250 600x250+0+0 8-bit sRGB 253c 53.1KB 0.000u 0:00.000

Thank you very much ,can you tell me how to optimise imagemagick to reduce computer memory consumption
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: PNG size become bigger when after thumbnail the png

Post by snibgo »

See http://www.imagemagick.org/script/architecture.php

Q8 uses half the memory of Q16.
snibgo's IM pages: im.snibgo.com
needkane
Posts: 47
Joined: 2014-09-11T02:19:30-07:00
Authentication code: 6789

Re: PNG size become bigger when after thumbnail the png

Post by needkane »

snibgo wrote:See http://www.imagemagick.org/script/architecture.php

Q8 uses half the memory of Q16.

Thank you very much,can you help me this issue viewtopic.php?f=3&t=27148
needkane
Posts: 47
Joined: 2014-09-11T02:19:30-07:00
Authentication code: 6789

Re: PNG size become bigger when after thumbnail the png

Post by needkane »

needkane wrote:
snibgo wrote:See http://www.imagemagick.org/script/architecture.php

Q8 uses half the memory of Q16.

Thank you very much,can you help me this issue viewtopic.php?f=3&t=27148

Sir,another quesstion :webp image become bigger too after thumbnail
Image:http://7te8ta.com1.z0.glb.clouddn.com/p ... pload.webp
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: PNG size become bigger when after thumbnail the png

Post by snibgo »

You can use "-quality" with webp to trade-off quality against size. For example:

Code: Select all

f:\web\im>%IM%convert upload.webp -thumbnail 200x -quality 10 x.webp
upload.webp is 5400 bytes. x.webp is 2034 bytes.
snibgo's IM pages: im.snibgo.com
needkane
Posts: 47
Joined: 2014-09-11T02:19:30-07:00
Authentication code: 6789

Re: PNG size become bigger when after thumbnail the png

Post by needkane »

snibgo wrote:You can use "-quality" with webp to trade-off quality against size. For example:

Code: Select all

f:\web\im>%IM%convert upload.webp -thumbnail 200x -quality 10 x.webp
upload.webp is 5400 bytes. x.webp is 2034 bytes.


Sir, the same question like bmp
Image:http://s3-us-west-2.amazonaws.com/qiniu-bs/bigger.png ( 720x300,57kb)
Command:
convert bigger.png -thumbnail 719x +repage result.png

We find the result.png width and height both less than original, but the image's size both bigger than original.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: PNG size become bigger when after thumbnail the png

Post by snibgo »

Pngcrush may be useful.
snibgo's IM pages: im.snibgo.com
needkane
Posts: 47
Joined: 2014-09-11T02:19:30-07:00
Authentication code: 6789

Re: PNG size become bigger when after thumbnail the png

Post by needkane »

snibgo wrote:Pngcrush may be useful.
Your means is imagemagick can't resolve?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: PNG size become bigger when after thumbnail the png

Post by snibgo »

As upthread: "The "256c" label has gone. The input had only 256 colours, but interpolated resizing has increased the number of colours, so the output isn't palleted." So use "-colors 255 -type Palette" again.
snibgo's IM pages: im.snibgo.com
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: PNG size become bigger when after thumbnail the png

Post by glennrp »

snibgo wrote:Pngcrush may be useful.
Pngcrush won't help much if there are more than 256 colors (including the background color) present.
needkane
Posts: 47
Joined: 2014-09-11T02:19:30-07:00
Authentication code: 6789

Re: PNG size become bigger when after thumbnail the png

Post by needkane »

glennrp wrote:
snibgo wrote:Pngcrush may be useful.
Pngcrush won't help much if there are more than 256 colors (including the background color) present.
pngquant is a good tool,but I want use imagemagick
needkane
Posts: 47
Joined: 2014-09-11T02:19:30-07:00
Authentication code: 6789

Re: PNG size become bigger when after thumbnail the png

Post by needkane »

snibgo wrote:As upthread: "The "256c" label has gone. The input had only 256 colours, but interpolated resizing has increased the number of colours, so the output isn't palleted." So use "-colors 255 -type Palette" again.
Do you know the rules
viewtopic.php?f=3&t=27130
needkane
Posts: 47
Joined: 2014-09-11T02:19:30-07:00
Authentication code: 6789

Re: PNG size become bigger when after thumbnail the png

Post by needkane »

snibgo wrote:What version of IM are you using?

With v6.9.0-0 I get:

Code: Select all

f:\web\im>%IM%identify bigger.png
bigger.png PNG 720x300 720x300+0+0 8-bit sRGB 256c 56.5KB 0.000u 0:00.000

f:\web\im>%IM%convert bigger.png -thumbnail 600x b.png

f:\web\im>%IM%identify b.png
b.png PNG 600x250 600x250+0+0 8-bit sRGB 124KB 0.000u 0:00.000
The width has shrunk to 600 pixels, as required. The size has more than doubled. We can see why: the "256c" label has gone. The input had only 256 colours, but interpolated resizing has increased the number of colours, so the output isn't palleted. I can cure this:

Code: Select all

f:\web\im>%IM%convert bigger.png -thumbnail 600x -colors 255 -type Palette b.png

f:\web\im>%IM%identify b.png
b.png PNG 600x250 600x250+0+0 8-bit sRGB 253c 53.1KB 0.000u 0:00.000

Image :http://s3-us-west-2.amazonaws.com/qiniu-bs/2.png
Type :Palette2

If use command:
convert 2.png -thumbnail 400x b.png //size bigger than origin

But use command like you :
convert 2.png -thumbnail 400x -colors 2 -type Palette b.png
or
convert 2.png -thumbnail 400x -colors 1 -type Palette b.png

The result only one color and Opaque
Post Reply