Sha256: 50b45f35aab1d7489753dd653ac27190589e2f1d9bf1631111401a7352a5b9e5
Contents?: true
Size: 1.91 KB
Versions: 5
Compression:
Stored size: 1.91 KB
Contents
task(:verify, :png_file) do |task, args| require 'rubygems' require 'bundler' Bundler.setup require 'chunky_png' require 'oily_png/oily_png_ext' class OilyPNG::Canvas < ChunkyPNG::Canvas extend OilyPNG::PNGDecoding include OilyPNG::PNGEncoding end file = args[:png_file] || ENV['PNG_FILE'] raise "Please specify a valid PNG file to verify!" unless File.exist?(file.to_s) decoding_reference = ChunkyPNG::Canvas.from_file(file) decoding_oily_png = OilyPNG::Canvas.from_file(file) if decoding_reference == decoding_oily_png puts "Decoding test succeeded!" else puts "Decoding test FAILED!" end oily_png = OilyPNG::Canvas.from_canvas(decoding_reference) [ChunkyPNG::FILTER_NONE, ChunkyPNG::FILTER_SUB, ChunkyPNG::FILTER_UP, ChunkyPNG::FILTER_AVERAGE, ChunkyPNG::FILTER_PAETH].each do |filter_method| encoding_reference = decoding_reference.to_blob(:filtering => filter_method, :color_mode => ChunkyPNG::COLOR_TRUECOLOR_ALPHA) encoding_oily_png = oily_png.to_blob(:filtering => filter_method, :color_mode => ChunkyPNG::COLOR_TRUECOLOR_ALPHA) if encoding_reference == encoding_oily_png puts "Encoding test succeeded for filter method #{filter_method}!" else puts "Encoding test FAILED for filter method #{filter_method}!" end end [ChunkyPNG::COLOR_GRAYSCALE, ChunkyPNG::COLOR_GRAYSCALE_ALPHA, ChunkyPNG::COLOR_INDEXED, ChunkyPNG::COLOR_TRUECOLOR, ChunkyPNG::COLOR_TRUECOLOR_ALPHA].each do |color_mode| encoding_reference = decoding_reference.to_blob(:filtering => ChunkyPNG::FILTER_NONE, :color_mode => color_mode) encoding_oily_png = oily_png.to_blob(:filtering => ChunkyPNG::FILTER_NONE, :color_mode => color_mode) if encoding_reference == encoding_oily_png puts "Encoding test succeeded for color mode #{color_mode}!" else puts "Decoding test FAILED for color mode #{color_mode}!" end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
oily_png-0.3.0 | tasks/testing.rake |
oily_png-0.2.0 | tasks/testing.rake |
oily_png-0.1.1 | tasks/testing.rake |
oily_png-0.1.0 | tasks/testing.rake |
oily_png-0.0.8 | tasks/testing.rake |