Skip to content

Instantly share code, notes, and snippets.

@TheAnonymous
Created November 15, 2014 15:35
Show Gist options
  • Save TheAnonymous/a03b2d9baf1260aa1364 to your computer and use it in GitHub Desktop.
Save TheAnonymous/a03b2d9baf1260aa1364 to your computer and use it in GitHub Desktop.
This is a small snippet to change the size of an input image to iconsize of Firefoxphone
require 'opencv'
include OpenCV
if ARGV.size == 0
puts "Usage: ruby #{__FILE__} ImageToLoadAndDisplay"
exit
end
image = nil
begin
image = CvMat.load(ARGV[0], CV_LOAD_IMAGE_UNCHANGED ) # Read the file.
rescue
puts 'Could not open or find the image.'
exit
end
sizes = [512,128,58,48,16]
sizes.each do |s|
size = CvSize.new(s,s)
tmp_image = image.resize(size)
tmp_image.save("Icon_#{s}.png")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment