wvanbergen / chunky_png

Read/write access to PNG images in pure Ruby.
https://chunkypng.com
MIT License
1.05k stars 101 forks source link

pHYs support #98

Open clord opened 9 years ago

clord commented 9 years ago

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.

wvanbergen commented 9 years ago

:+1: this would be a nice addition.

It's unlikely I will have time to work on this anytime soon though, but feel free to ask me to help if you are willing to take a stab at it.