chunkypng

Corp image with ruby

微笑、不失礼 提交于 2019-12-13 08:51:03
问题 I try to corp an image how you can see in my last line of code i trigger: p.corp!(0,0,p.width,black_last).save('bearbeitet.png') But somehow i get this error: bild.rb:29:in `<main>': undefined method `corp!' for #<ChunkyPNG::Canvas:0x24f34 50> (NoMethodError) Why? The docu for corp: http://rdoc.info/gems/chunky_png/ChunkyPNG/Canvas/Operations#crop-instance_method My whole code: Thanks! require 'mini_magick' require 'chunky_png' i = MiniMagick::Image.open("a.jpg") i.format('png') p = ChunkyPNG

How do I get the hex value from each pixel in RMagick or Chunky_PNG?

给你一囗甜甜゛ 提交于 2019-12-11 20:37:41
问题 I'm trying to read the value of each pixel as hex (HTML notation) using RMagick or Chunky_PNG e.g. #5DBCD2 . At the moment I have the below which kind of does what I want but I couldn't find the right way to actually read the hex value. I'd prefer to use Chunky_PNG though, thanks! require 'chunky_png' img = ChunkyPNG::Image.from_file("image.png") height = img.dimension.height width = img.dimension.width height.times do |i| width.times do |j| p [ChunkyPNG::Color.r(img[j,i]), ChunkyPNG::Color.g