-
-
Save revskill10/3936462 to your computer and use it in GitHub Desktop.
pdf to jpg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def convert_to_previews(new_file) | |
name = File.basename(current_path) | |
images = Magick::Image.read(current_path) do | |
self.background_color = "white" # does not work for me :/ | |
end | |
if images.length > 0 | |
save_path = "#{Rails.root}/public/uploads/#{model.class.to_s.underscore}/file/#{model.id}/slides" | |
Dir.mkdir save_path unless File.exists? save_path | |
images.each_with_index do |image, index| | |
image.border!(0, 0, "white") | |
image.resize_to_fit!(1024, 1024).write("#{save_path}/sheet_#{index}.jpg") | |
image.resize_to_fit!(70, 100000).write("#{save_path}/preview_sheet_#{index}.jpg") | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment