Skip to content

Instantly share code, notes, and snippets.

View prgrmr-yn's full-sized avatar

yat prgrmr-yn

View GitHub Profile
@prgrmr-yn
prgrmr-yn / gist:a556592ee8a8235c94811afafd3a5254
Created August 4, 2023 09:34
Instantly convert heic to jpg
#!/usr/bin/env ruby
require 'shellwords'
files = `find . -iname '*.heic'`.split("\n")
files.each do |original_file|
output_file = original_file.gsub(/\.heic\z/i, ' Converted.jpg')
if File.exist?(output_file)
STDERR.puts "Skipping output #{output_file} exists."
else
@prgrmr-yn
prgrmr-yn / gist:a13d0722a4d55ce7e806d0521a8c3a48
Created August 19, 2023 11:20
Convert heic and webp files to jpg files
#!/usr/bin/env ruby
require 'shellwords'
def convert_to_jpg(original_file, output_file)
cmd = "convert #{Shellwords.escape(original_file)} #{Shellwords.escape(output_file)}"
success = system(cmd)
if success
File.delete(original_file) # Deletes the original file if the conversion was successful
puts "Deleted original file: #{original_file}"