Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated file much bigger than needed #89

Open
ryana opened this issue Oct 24, 2015 · 0 comments
Open

Generated file much bigger than needed #89

ryana opened this issue Oct 24, 2015 · 0 comments

Comments

@ryana
Copy link

ryana commented Oct 24, 2015

Hey there,

This is more of a question than an issue, but I couldn't find a Google Group-ish forum to ask questions.

I just generated this file:

2.1.2 :003 > File.open('test.png', 'wb+') {|f| f.write IMGKit.new('<html><body><ul><li>hi</li></ul></body></html').to_png }

The resulting image looked perfect, but it was huge. I ran in through convert with no options and:

ra:app(master) ryan$ ll test.png 
-rw-r--r--@ 1 ryan  staff  176553 Oct 24 09:24 test.png
ra:app(master) ryan$ convert test.png test-c.png
ra:app(master) ryan$ ll test*
-rw-r--r--  1 ryan  staff     733 Oct 24 09:29 test-c.png
-rw-r--r--@ 1 ryan  staff  176553 Oct 24 09:24 test.png
ra:app(master) ryan$ 

The "compressed" image is the same resolution and looks perfect. file tells me this:

ra:app(master) ryan$ file test.png 
test.png: PNG image data, 1024 x 43, 8-bit/color RGBA, non-interlaced
ra:app(master) ryan$ file test-c.png 
test-c.png: PNG image data, 1024 x 43, 8-bit colormap, non-interlaced
ra:app(master) ryan$ 

I ran a more complex image (a screenshot of Ramen) and got similar results:

ra:app(master) ryan$ ll ramen.png 
-rw-r--r--  1 ryan  staff  20468984 Oct 24 09:32 ramen.png
ra:app(master) ryan$ convert ramen.png ramen-c.png
ra:app(master) ryan$ ll ramen*
-rw-r--r--  1 ryan  staff    565074 Oct 24 09:32 ramen-c.png
-rw-r--r--  1 ryan  staff  20468984 Oct 24 09:32 ramen.png
ra:app(master) ryan$ file ramen.png 
ramen.png: PNG image data, 1024 x 4988, 8-bit/color RGBA, non-interlaced
ra:app(master) ryan$ file ramen-c.png 
ramen-c.png: PNG image data, 1024 x 4988, 8-bit/color RGBA, non-interlaced

Is there some default option I should be changing in IMGkit to get this better efficiency?

Here are the images in question:

test:
test.png

test-c:
test-c.png

ramen (which I won't embed because it's 20MB):
ramen.png

ramen-c:
ramen-c.png

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant