wvanbergen / chunky_png Goto Github PK
View Code? Open in Web Editor NEWRead/write access to PNG images in pure Ruby.
Home Page: https://chunkypng.com
License: MIT License
Read/write access to PNG images in pure Ruby.
Home Page: https://chunkypng.com
License: MIT License
Hello
I'm gettin gthis error when try to use the gem
/var/lib/gems/1.9.1/gems/chunky_png-1.3.3/lib/chunky_png/canvas/drawing.rb:97:in line_xiaolin_wu': undefined method
-' for nil:NilClass (NoMethodError)
from /var/lib/gems/1.9.1/gems/chunky_png-1.3.3/lib/chunky_png/canvas/drawing.rb:235:in rect' from sample.rb:22:in
It would be nice to have api support for generating the pHYs section, as it is part of the PNG Specification.
It's possible to do it manually if there is already a chunk:
stream.each_chunk do |c|
if c.type == 'pHYs'
c.content = [5906, 5906, 1] .pack('N2C')
end
end
But it's not as easy to insert this node into a fresh PNG. I plan on inserting a ChunkyPNG::Chunk::Generic
into #other_chunks
, but this feels really a tad dirty. I propose that Datastream
have ChunkyPNG::Chunk::Phys
and a corresponding phys_chunk
accessor.
Hi there !! I am comparing two same .png files and i have got error after that....
puts "image changed (%): #{(diff.inject {|sum, value| sum + value} / images.first.pixels.length) * 100}%"
NoMethodError: undefined method `/' for nil:NilClass
I use Chunky_png (v1.2.9), ruby (ruby-2.0.0-p247)
Where is it problem here?
I was poking around the options for Zlib::Deflate, and noticed the RLE strategy, which is described in the Ruby docs as:
Designed for better compression of PNG image data
I thought, "hey that sounds great, I'll give it a spin." So, I changed this line:
streamdata = Zlib::Deflate.deflate(data, level)
To this:
deflater = Zlib::Deflate.
new(level, Zlib::MAX_WBITS, Zlib::DEF_MEM_LEVEL, Zlib::RLE)
streamdata = deflater.deflate(data)
deflater.close
Unfortunately, this had the opposite effect that I hoped for. With the previous code my PNG was ~2MiB, and after the change, it was ~5.4MiB.
Anyway, I figured I'd just share my findings in case you happen to have a better understanding.
Since borders can now be trimmed, it seems logical to also permit the reverse process of adding a border to a ChunkyPNG::Canvas
. I'd be happy to take the initiative, but I wanted to ask whether you think it should be added to Drawing
or Operations
. Also, should the interface be a simple size and color argument pair, or something more elaborate that would permit variadic border specifications a la CSS's border
property?
The docs for Color.from_hsv claim that hue can range from 0 through 360:
# @param [Fixnum] hue The hue component (0-360)
But if a hue of 360 is given:
gem "chunky_png", "1.3.4"
require "chunky_png"
ChunkyPNG::Color.from_hsv(360.0, 1.0, 1.0)
Then an exception is thrown:
/home/wayne/.rvm/gems/ruby-2.2.0/gems/chunky_png-1.3.4/lib/chunky_png/color.rb:199:in `from_hsv': undefined method `map!' for nil:NilClass (NoMethodError)
from /tmp/chunky.rb:5:in `<main>'
If the docs are correct, then a hue %= 360
in #cylindrical_to_cubic will fix the code. If the code is correct, then the docs should probably indicate that the upper limit is exclusive rather than inclusive. Perhaps using the Ruby range notation of three dots for exclusive and two dots for inclusive would do it:
# @param [Fixnum] hue The hue component (0...360)
# @param [Fixnum] saturation The saturation component (0..1)
# @param [Fixnum] value The value (brightness) component (0..1)
This issue affects .from_hsl as well.
Whichever is wrong, the docs or the code, I'd be glad to create a pull request for it.
Chunky PNG seems to have a dependency on RMagick in https://github.com/wvanbergen/chunky_png/blob/master/lib/chunky_png/rmagick.rb#L1. It's also used in the specs https://github.com/wvanbergen/chunky_png/blob/master/spec/chunky_png/rmagick_spec.rb.
However I can't find any dependency on it in the gemspec. When I bundle install it doesn't appear in the Gemfile.lcok either.
Here's the right one:
def decode_png_resample_4bit_value(value)
case value
when 0x00; 0
when 0x01; 17
when 0x02; 34
when 0x03; 51
when 0x04; 68
when 0x05; 85
when 0x06; 102
when 0x07; 119
when 0x08; 136
when 0x09; 153
when 0x0a; 170
when 0x0b; 187
when 0x0c; 204
when 0x0d; 221
when 0x0e; 238
when 0x0f; 255
end
end
You can check by opening basi0g04.png
or basn0g04.png
in GIMP and comparing color values of very last pixel - GIMP gives 0xEEEEEE
, and ChunkyPNG 0xEFEFEF
PS: it also can be a little simpler: :)
def decode_png_resample_4bit_value(value)
value*17
end
Move useful stuff to chunkypng.com
I use iPad to take a screenshot and save as png image.
Its size is about 1.3M.
When I run the code below:
images.first.height.times do |y|
images.first.row(y).each_with_index do |pixel, x|
diff << [x,y] unless pixel == images.last[x,y]
end
end
There will be an error "out of bound " or sth.
Sorry I cannot remember the detail error message.
How can I solve this issue.
I am trying to create a color from a rgb triplel, and I am doing it like this:
ChunkyPNG::Color.from_rgb_stream('255,255,0')
But it doesn't create the color I am looking for. It is always a grey. I am using this in order to create a new image as:
background = ChunkyPNG::Image.new(bg_width, bg_height, ChunkyPNG::Color.from_rgb_stream('255,255,0'))
I am not sure if the input should be in another format, or am I missing something. I have tried also passing rgb(255,255,0) with same result.
When doing this:
ChunkyPNG::Color.rgba(0,255,blue.to_i,0.546875)
I get an:
TypeError (Float can't be coerced into Float for bitwise arithmetic):
So, I checked the source and it seems it is expecting an integer as the alpha value. Shouldn't it be accepting a Float?
I will try to do a Pull Request based on your comments.
To decrease the resulting PNG file size. At least for indexed images, but maybe grayscale images as well.
Can chunky_png draw text with specifing (x,y) ? I have tried to read the source code, but I found nothing about it.
Please tell me if will be reasonable to create matrix filter that takes as argument, for example blur filter:
[ [1, 1, 1],
[1, 1, 1],
[1, 1, 1]]
this will allow to create gaussian, blur, edge detection and much other filters.
If yes, I'll gladly create such filter
Thanks for your greate gem. Recently I met a problem, that I create a png image, its dpi is 72 dpi by default. However my printer is 300dpi. The image printed was somehow blur because of its dpi.
I'm wonder does this gem support changing or setting its dpi?
Thanks a lot.
what's the point in line 19:
resampled_image = self.class.new(new_width.to_i, new_height.to_i)
this variable is never used
and resulting pixels substitute current ones
you should
Also there is an another problem in line 19: it uses self.class constructor instead of ChunkyPNG::Canvas one, it results in error when calling this function from child class that doesn't support constructor with (width,height) pair - for example from Compass::Magick::Canvas, so if you plan to leave line 19 it should be rewritten like
resampled_image = ChunkyPNG::Canvas.new(new_width.to_i, new_height.to_i)
it's metadata, not metdata on this method:
def initialize_copy(other)
super(other)
@metdata = other.metadata
end
It was causing this error:
/gems/ree-1.8.7-2010.02/gems/chunky_png-0.9.0/lib/chunky_png/image.rb: undefined method `metadata=' for #ChunkyPNG::Canvas:0x2c4b088
I have pictures of 1 mega and it takes like 20 seconds to load, any possibility to solve this?
how can i resize the picture beforehand? (not with RMagick)
def self.from_datastream(ds)
image = super(ds)
image.metadata = ds.metadata
return image
end
We had this bug where metadata is not defined on instance of ChunkyPNG::Canvas. Which is correct. (There is no metadata attribute on ChunkyPNG::Canvas).
Commenting out the following fixes our bug.
image.metadata = ds.metadata
Should ChunkyPNG::Canvas instance have metadata attribute?
By default, StringIO will use the external string encoding. In most cases, 'UTF-8' will be used. This creates an issue when using StringIO to generate a blob. (By definition, a blob should use 'ASCII-8BIT'):
https://github.com/wvanbergen/chunky_png/blob/dc526b4a/lib/chunky_png/datastream.rb#L177
This could easily be fixed by adding str.set_encoding('ASCII-8BIT')
after the string creation.
See point 5 of http://blog.rayapps.com/2013/03/11/7-things-that-can-go-wrong-with-ruby-19-string-encodings/ for further details.
I've got a PNG file, attached, that refuses to load in ChunkyPNG. Any idea what might be going wrong? Let me know if I can help debug any further.
irb(main):004:0> ChunkyPNG::Image.from_file('tmp.png')
NoMethodError: undefined method `unpack' for nil:NilClass
from /usr/local/opt/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/chunky_png-1.3.1/lib/chunky_png/chunk.rb:21:in `read'
from /usr/local/opt/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/chunky_png-1.3.1/lib/chunky_png/datastream.rb:78:in `from_io'
from /usr/local/opt/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/chunky_png-1.3.1/lib/chunky_png/datastream.rb:66:in `block in from_file'
from /usr/local/opt/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/chunky_png-1.3.1/lib/chunky_png/datastream.rb:66:in `open'
from /usr/local/opt/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/chunky_png-1.3.1/lib/chunky_png/datastream.rb:66:in `from_file'
from /usr/local/opt/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/chunky_png-1.3.1/lib/chunky_png/canvas/png_decoding.rb:53:in `from_file'
from (irb):4
from /usr/local/opt/rbenv/versions/2.1.2/bin/irb:11:in `<main>'
When loading an indexed png file, and saving it again, the palette is not preserved correctly. Only colors used are preserved, and their order is also messed up. For pixel art, it's important to keep the palette intact and sorted as it was in the original image. That's why I think images loaded as indexed files png files should have their palette preserved in the original order with the original colors.
Example of the problem:
image = ChunkyPNG::Image.from_file('tiles_1000_world.png')
image.save("try2.png", :color_mode => ChunkyPNG::COLOR_INDEXED)
Thanks, and kind regards,
Beoran.
I'd like to use ChunkyPNG to accurately compare the perceptual difference of 2 colors. The way to do this is by calculating a Delta E. There are a few formulas to do this of increasing complexity and accuracy, but they all require that the two colors be represented in the Lab colorspace, not RGB. To get from RGB to Lab requires additional math. It would be really awesome if there was a Delta E function in ChunkyPNG, but I think I'd be happy to start with just a set of Lab methods.
I've done this in a previous project, and I used the formulas here. They have one that goes from RGB to XYZ, and a few that go from XYZ to the different Lab colorspaces.
More info:
Hi @wvanbergen,
We have this issue: https://groups.google.com/forum/#!topic/compass-users/U6xMb5INZhA
I suspect there's some way we can mitigate this in the compass spriting code. Can you please advise?
I'm using ChunkyPNG to crop areas from web page screenshots, and find that it takes more than 10 seconds when a big file (about 1.8M) is opened.
My code is:
img = ChunkyPNG::Image.from_file 'path/to/screenshot.png'
An error is exposed when I cancel the script:
^C/Users/.../.rvm/gems/ruby-1.9.3-p448/gems/chunky_png-1.2.9/lib/chunky_png/canvas/png_decoding.rb:400:in `block in decode_png_image_pass': Interrupt
Besides, when I change to OilyPNG, it works well.
"undefined method `size' for nil:NilClass" error while installing chunky_png gem
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]
$ gem install chunky_png -v '1.2.8' --backtrace
ERROR: While executing gem ... (NoMethodError)
undefined method `size' for nil:NilClass
/home/smr/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/package/tar_reader/entry.rb:127:in `read'
/home/smr/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/package.rb:289:in `block in digest'
/home/smr/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/package.rb:286:in `each'
/home/smr/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/package.rb:286:in `digest'
/home/smr/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/package.rb:526:in `block in verify_files'
/home/smr/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/package/tar_reader.rb:64:in `each'
/home/smr/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/package.rb:517:in `verify_files'
/home/smr/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/package.rb:474:in `block (2 levels) in verify'
/home/smr/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/package/tar_reader.rb:28:in `new'
/home/smr/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/package.rb:471:in `block in verify'
/home/smr/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/package.rb:470:in `open'
/home/smr/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/package.rb:470:in `verify'
/home/smr/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/package.rb:451:in `spec'
/home/smr/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/installer.rb:190:in `spec'
/home/smr/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/installer.rb:493:in `ensure_loadable_spec'
/home/smr/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/installer.rb:756:in `pre_install_checks'
/home/smr/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/installer.rb:207:in `install'
/home/smr/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/dependency_installer.rb:372:in `block in install'
/home/smr/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/dependency_installer.rb:332:in `each'
/home/smr/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/dependency_installer.rb:332:in `each_with_index'
/home/smr/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/dependency_installer.rb:332:in `install'
/home/smr/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/commands/install_command.rb:166:in `block in execute'
/home/smr/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/commands/install_command.rb:158:in `each'
/home/smr/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/commands/install_command.rb:158:in `execute'
/home/smr/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/command.rb:305:in `invoke_with_build_args'
/home/smr/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/command_manager.rb:170:in `process_args'
/home/smr/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/command_manager.rb:130:in `run'
/home/smr/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/gem_runner.rb:60:in `run'
/home/smr/.rvm/rubies/ruby-2.0.0-p247/bin/gem:21:in `<main>'
from readme "Also check out the following screencast by John Davison, which illustrates basic usage of the library", link to http://devcasts.co/ruby-chunky_png-a-great-gem-for-on-the-fly-png-manipulation that follows is not working
It would be great to be able to stream multiple images in and write out to one image as a composition.
Are you planning to add this feature?
It could be quite useful (at least for reading), since tools like gimp automatically choose the lowest depth possibile when saving an indexed image.
Great library - would be a nice addition to draw text onto an image.
Per the PNG specification at http://www.w3.org/TR/PNG/, chunks may be empty as long as they have a length of 0 specified.
5.3 Chunk layout
Each chunk consists of three or four fields (see figure 5.1). The meaning of the fields is described in Table 5.1. The chunk data field may be empty.
ChunkyPNG raises an exception on empty IDAT chunks when it should allow them.
Happy to whip up a PR for this, just wanted to check to see if the exception is being raised for other reasons.
We're using REE for production (ree-1.8.7-2011.03), and it run chunky_png just fine — only it's about 10 times slower when generating PNGs (with Compass). It's 100% reproducable, whatever the input files are.
My only guess right now is that REE's GC is struggling with the specific type of computation that Chunky performs.
Has anyone else experienced this?
on compass compile
$ compass compile --trace
Zlib::BufError on line ["230"] of /var/lib/gems/2.0.0/gems/chunky_png-1.3.0/lib/chunky_png/chunk.rb: buffer error
/var/lib/gems/2.0.0/gems/chunky_png-1.3.0/lib/chunky_png/chunk.rb:230:in `combine_chunks'
/var/lib/gems/2.0.0/gems/chunky_png-1.3.0/lib/chunky_png/datastream.rb:148:in `imagedata'
/var/lib/gems/2.0.0/gems/chunky_png-1.3.0/lib/chunky_png/canvas/png_decoding.rb:88:in `from_datastream'
/var/lib/gems/2.0.0/gems/chunky_png-1.3.0/lib/chunky_png/image.rb:74:in `from_datastream'
/var/lib/gems/2.0.0/gems/chunky_png-1.3.0/lib/chunky_png/canvas/png_decoding.rb:53:in `from_file'
/var/lib/gems/2.0.0/gems/compass-0.12.2/lib/compass/sass_extensions/sprites/engines/chunky_png_engine.rb:15:in `block in construct_sprite'
/var/lib/gems/2.0.0/gems/compass-0.12.2/lib/compass/sass_extensions/sprites/engines/chunky_png_engine.rb:14:in `each'
/var/lib/gems/2.0.0/gems/compass-0.12.2/lib/compass/sass_extensions/sprites/engines/chunky_png_engine.rb:14:in `construct_sprite'
/var/lib/gems/2.0.0/gems/compass-0.12.2/lib/compass/sass_extensions/sprites/sprite_methods.rb:62:in `generate'
/var/lib/gems/2.0.0/gems/compass-0.12.2/lib/compass/sass_extensions/functions/sprites.rb:122:in `sprite_url'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/script/funcall.rb:113:in `_perform'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/script/node.rb:40:in `perform'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/perform.rb:298:in `visit_prop'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/base.rb:37:in `visit'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/perform.rb:100:in `visit'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/perform.rb:268:in `block (3 levels) in visit_mixin'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/perform.rb:268:in `map'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/perform.rb:268:in `block (2 levels) in visit_mixin'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/perform.rb:121:in `with_environment'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/perform.rb:268:in `block in visit_mixin'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/perform.rb:70:in `perform_arguments'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/perform.rb:263:in `visit_mixin'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/base.rb:37:in `visit'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/perform.rb:100:in `visit'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/base.rb:53:in `block in visit_children'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/base.rb:53:in `map'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/base.rb:53:in `visit_children'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/perform.rb:109:in `block in visit_children'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/perform.rb:121:in `with_environment'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/perform.rb:108:in `visit_children'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/base.rb:37:in `block in visit'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/perform.rb:320:in `visit_rule'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/base.rb:37:in `visit'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/perform.rb:100:in `visit'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/base.rb:53:in `block in visit_children'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/base.rb:53:in `map'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/base.rb:53:in `visit_children'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/perform.rb:109:in `block in visit_children'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/perform.rb:121:in `with_environment'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/perform.rb:108:in `visit_children'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/base.rb:37:in `block in visit'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/perform.rb:320:in `visit_rule'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/base.rb:37:in `visit'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/perform.rb:100:in `visit'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/base.rb:53:in `block in visit_children'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/base.rb:53:in `map'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/base.rb:53:in `visit_children'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/perform.rb:109:in `block in visit_children'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/perform.rb:121:in `with_environment'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/perform.rb:108:in `visit_children'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/base.rb:37:in `block in visit'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/perform.rb:320:in `visit_rule'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/base.rb:37:in `visit'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/perform.rb:100:in `visit'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/perform.rb:227:in `block in visit_import'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/perform.rb:227:in `map'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/perform.rb:227:in `visit_import'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/base.rb:37:in `visit'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/perform.rb:100:in `visit'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/perform.rb:227:in `block in visit_import'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/perform.rb:227:in `map'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/perform.rb:227:in `visit_import'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/base.rb:37:in `visit'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/perform.rb:100:in `visit'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/base.rb:53:in `block in visit_children'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/base.rb:53:in `map'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/base.rb:53:in `visit_children'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/perform.rb:109:in `block in visit_children'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/perform.rb:121:in `with_environment'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/perform.rb:108:in `visit_children'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/base.rb:37:in `block in visit'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/perform.rb:128:in `visit_root'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/base.rb:37:in `visit'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/perform.rb:100:in `visit'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/visitors/perform.rb:7:in `visit'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/tree/root_node.rb:20:in `render'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/engine.rb:315:in `_render'
/var/lib/gems/2.0.0/gems/sass-3.2.14/lib/sass/engine.rb:262:in `render'
/var/lib/gems/2.0.0/gems/compass-0.12.2/lib/compass/compiler.rb:140:in `block (2 levels) in compile'
/var/lib/gems/2.0.0/gems/compass-0.12.2/lib/compass/compiler.rb:126:in `timed'
/var/lib/gems/2.0.0/gems/compass-0.12.2/lib/compass/compiler.rb:139:in `block in compile'
/var/lib/gems/2.0.0/gems/compass-0.12.2/lib/compass/logger.rb:45:in `red'
/var/lib/gems/2.0.0/gems/compass-0.12.2/lib/compass/compiler.rb:138:in `compile'
/var/lib/gems/2.0.0/gems/compass-0.12.2/lib/compass/compiler.rb:118:in `compile_if_required'
/var/lib/gems/2.0.0/gems/compass-0.12.2/lib/compass/compiler.rb:103:in `block (2 levels) in run'
/var/lib/gems/2.0.0/gems/compass-0.12.2/lib/compass/compiler.rb:101:in `each'
/var/lib/gems/2.0.0/gems/compass-0.12.2/lib/compass/compiler.rb:101:in `block in run'
/var/lib/gems/2.0.0/gems/compass-0.12.2/lib/compass/compiler.rb:126:in `timed'
/var/lib/gems/2.0.0/gems/compass-0.12.2/lib/compass/compiler.rb:100:in `run'
/var/lib/gems/2.0.0/gems/compass-0.12.2/lib/compass/commands/update_project.rb:45:in `perform'
/var/lib/gems/2.0.0/gems/compass-0.12.2/lib/compass/commands/base.rb:18:in `execute'
/var/lib/gems/2.0.0/gems/compass-0.12.2/lib/compass/commands/project_base.rb:19:in `execute'
/var/lib/gems/2.0.0/gems/compass-0.12.2/lib/compass/exec/sub_command_ui.rb:43:in `perform!'
/var/lib/gems/2.0.0/gems/compass-0.12.2/lib/compass/exec/sub_command_ui.rb:15:in `run!'
/var/lib/gems/2.0.0/gems/compass-0.12.2/bin/compass:30:in `block in <top (required)>'
/var/lib/gems/2.0.0/gems/compass-0.12.2/bin/compass:44:in `call'
/var/lib/gems/2.0.0/gems/compass-0.12.2/bin/compass:44:in `<top (required)>'
/usr/local/bin/compass:23:in `load'
/usr/local/bin/compass:23:in `<main>'
def indexable?
size < 256
end
Shouldn't it be
size <= 256
?
If there are 256 colors it's still ok, since you can use byte values from 0 to 255. Nice job, I love chuncky_png! Bye
(Please forgive me for my bad English)
I am using chunky png to generate image sprites. I have acceptance tests that compare the resulting sprite using a crop with the generated stylesheet's offsets with the individual images that make up the sprite, With the newer versions, ChunkyPng/OilyPng now generate sprites with a 52% difference for an individual image comparison. My code has not changed, and as far as I can tell, neither has your interface.
image_list = sprite_pieces.map do |sp|
sprite_piece_path = image_computed_full_path(sp.path)
sp_image = ChunkyPNG::Image.from_file(sprite_piece_path)
sp_image
end
@sprite = ChunkyPNG::Image.new(width, height, ChunkyPNG::Color::TRANSPARENT)
image_list.each_with_index do |image, i|
@sprite.replace(image, sprite_pieces[i].details.x, sprite_pieces[i].details.y)
end
Have you changed any of the underlying implementation that generates the pngs when replace is used? If there is anything I need to change due to a code change on your end, please advise.
For reference:
Cheers,
Sam
It would be nice to have some way to calculate the negative of a given colour.
I set
:color_mode => ChunkyPNG::COLOR_INDEXED
and got error
can't convert nil into Integer
(in /Users/doabit/Practice/rails3.1/sprite/app/assets/stylesheets/posts.css.scss)
The calculation goes wrong, if an antialiased image is composed with a transparent background. The colors at the border will be mixed with black. You’ll find some examples here:
If one (background or foreground image) is totally transparent the new color shouldn’t be calculated but copied. I did this here and it works well.
I've had a few people hope in compass IRC and ask me if its possible? any plans to support it?
http://techblog.floorplanner.com/tag/chunky_png in the last section is dead
Add bezier curves as a drawing operations, preferably with ant-aliasing.
Say I have an image that looks like this: http://www.pencils.com/skin/frontend/pencilsDotCom/mainTheme/img/logo.png
With ChunkyPNG how could I add a grey background so that the letters would actually be visible?
I fail to see that in the docs, so any help would be gladly appreciated.
Do you think it's within the scope of the project to allow colors to be converted to their closest 256-color terminal equivalents? Strange as it may seem, I've stumbled upon a use for this sort of thing and would be willing to package up the code for ChunkyPNG if you're interested.
I want to add text to the image, but I coudnt find any method to do that. Is there any method or its a feature not available in chunky yet?
I found a problem with writing pngs with color mode 0 and 1-bit depth when using ruby 2.0.0p247. The error does not occur with ruby versions < 2. This is an example of how to reproduce it:
appel:code niels$ ruby --version
ruby 1.9.3p448 (2013-06-27 revision 41675) [x86_64-darwin12.5.0]
appel:code niels$ irb -r qrencoder
irb(main):001:0> qrcode = QREncoder.encode("Hello world!")
=> #<QREncoder::QRCode:0x007fd1a98417a0>
irb(main):002:0> qrcode.save_png("/tmp/helloqr.png")
=> #<File:/tmp/helloqr.png (closed)>
irb(main):003:0> exit
appel:code niels$ rbenv local 2.0.0-p247
appel:code niels$ rbenv rehash
appel:code niels$ ruby --version
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.5.0]
appel:code niels$ irb -r qrencoder
irb(main):001:0> qrcode = QREncoder.encode("Hello world!")
=> #<QREncoder::QRCode:0x007fcf43825d10>
irb(main):002:0> qrcode.save_png("/tmp/helloqr2.png")
ChunkyPNG::NotSupported: No encoder found for color mode 0 and 1-bit depth!
from /Users/niels/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/chunky_png-1.2.5/lib/chunky_png/canvas/png_encoding.rb:370:in `encode_png_pixels_to_scanline_method'
from /Users/niels/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/chunky_png-1.2.5/lib/chunky_png/canvas/png_encoding.rb:210:in `encode_png_image_pass_to_stream'
from /Users/niels/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/chunky_png-1.2.5/lib/chunky_png/canvas/png_encoding.rb:174:in `encode_png_image_without_interlacing'
from /Users/niels/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/chunky_png-1.2.5/lib/chunky_png/canvas/png_encoding.rb:161:in `encode_png_pixelstream'
from /Users/niels/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/chunky_png-1.2.5/lib/chunky_png/canvas/png_encoding.rb:85:in `to_datastream'
from /Users/niels/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/chunky_png-1.2.5/lib/chunky_png/image.rb:62:in `to_datastream'
from /Users/niels/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/chunky_png-1.2.5/lib/chunky_png/canvas/png_encoding.rb:35:in `write'
from /Users/niels/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/chunky_png-1.2.5/lib/chunky_png/canvas/png_encoding.rb:43:in `block in save'
from /Users/niels/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/chunky_png-1.2.5/lib/chunky_png/canvas/png_encoding.rb:43:in `open'
from /Users/niels/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/chunky_png-1.2.5/lib/chunky_png/canvas/png_encoding.rb:43:in `save'
from /Users/niels/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/qrencoder-1.4.1/lib/qrencoder/png.rb:27:in `method_missing'
from /Users/niels/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/qrencoder-1.4.1/lib/qrencoder/qrcode.rb:11:in `save_png'
from (irb):2
from /Users/niels/.rbenv/versions/2.0.0-p247/bin/irb:12:in `<main>'
irb(main):003:0>
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.