Skip to content

Instantly share code, notes, and snippets.

@Pauloparakleto
Last active October 1, 2020 17:24
Show Gist options
  • Save Pauloparakleto/8a0b533837a45eb842180f9243cf394b to your computer and use it in GitHub Desktop.
Save Pauloparakleto/8a0b533837a45eb842180f9243cf394b to your computer and use it in GitHub Desktop.
Tired opening many images, convert it to jpg before sharing it with your friends? This ruby script use minimagick to read images and write it where you want. In general, the file name has a base like "IMG" + "(n+1)". Thus the script auto increment the last part, convert and write the correspondent name.
require 'mini_magick'
#Criar script IMG_#{numero + 1} for each loop
initial_number = 3746
final_number = 3774
image_name = ""
image_name_converted = ""
while initial_number < final_number
initial_number = initial_number + 1
p image_name = "IMG_" + "#{initial_number}" + ".CR2"
p image_name_converted = "IMG_" + "#{initial_number}" + ".jpg"
image = MiniMagick::Image.open("C:/path/to/open/#{image_name}")
p image.path
image.write("C:/path/to/write/#{image_name_converted}")
p "Image converted and saved at C:/Users/alpar/Desktop/paulo_e_louis_jpg/"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment