Imagemagick - File Naming

Posted by Josh Crowder on Stack Overflow See other posts from Stack Overflow or by Josh Crowder
Published on 2010-04-07T23:06:23Z Indexed on 2010/04/07 23:13 UTC
Read the original article Hit count: 404

I am using the convert command to convert a pdf to multiple pngs, I need the naming conventions to be slide-##.png at the moment they come out like slide-1.png but because there is 20+ slides when I loop through them to add them into the model the order comes up wrong, so it looks like slide-1.png slide-10.png slide-11.png and so on, how can I force convert to use double numbers like 01 02 03 and so forth or is there a better way to loop through them, this is the code I have at the moment

  def convert_keynote_to_slides
    system('convert -size 640x300 ' +   keynote.queued_for_write[:original].path + ' ~/rails/arcticfox/public/system/keynotes/slides/'+File.basename( self.keynote_file_name )+'0%d.png')

    slide_basename = File.basename( self.keynote_file_name )

    files = Dir.entries('/Users/joshcrowder/rails/arcticfox/public/system/keynotes/slides')
    for file in files
      #puts file if file.include?(slide_basename +'-')
      self.slides.build("slide" => "#{file}") if file.include?(slide_basename)
    end

  end

© Stack Overflow or respective owner

Related posts about imagemagick

Related posts about rmagick