Skip to content
Squeegy edited this page Sep 12, 2010 · 3 revisions

Are you upgrading your live app to the new file store creation date based format? Did you start out with PNG image storage, and later realize you need to store with the more space economic JPG instead? Not problem, Fleximage provides some rake tasks to help you out.

Each conversion rake task requires that you tell it the class for which you are changing the file store. For example, if you want to change to the new creation date based storage structure, for the class Photo, you can run a rake task like this:

rake fleximage:convert:to_nested FLEXIMAGE_CLASS=Photo

Or if you want to run this on your production database

rake fleximage:convert:to_nested FLEXIMAGE_CLASS=Photo RAILS_ENV=production

After you run any of these tasks, make sure to update your model class acts_as_fleximage configuration is correct. These tasks affect the use_creation_date_based_directories and image_storage_format. Otherwise, the plugin will not find your master images for rendering.


IMPORTANT

These tasks manipulate the source files that make up your images. I take no responsibility if these rake tasks delete all your images. It is highly advised you back up you master image directory before running any of these tasks on your production site.


Here are all the conversion tasks:

Directory formats

  • fleximage:convert:to_nested
    Converts your master image store from the flat based path/to/images/123.png format to the creation date based format path/to/images/2008/11/12/123.png based format. Use this task if you are upgrading from an older version of Fleximage.
  • fleximage:convert:to_flat
    Converts your master image store from the creation date based path/to/images/2008/11/12/123.png format to the flat format path/to/images/123.png format. Note this will leave the date based directories in place, but they will be empty and can be easily deleted by hand since the top level is just grouped by year.

Image formats

  • fleximage:convert:to_jpg
    Converts all your stored master images from PNG format to JPG format. This will introduce artifacts into your previously lossless master images.
  • fleximage:convert:to_png
    Converts all your stored master images from JPG format to PNG format. They will now takes up much more space, but all future images will be stored in a lossless format.

DB / Filesystem storage conversion

To run either of these tasks your model and database schema must be setup for database storage. See DatabaseOrFilesystemStorage.

  • fleximage:convert:to_db
    Convert master image storage to use the database. Loads all file-stored images into the database.
  • fleximage:convert:to_filestore
    Convert master image storage to use the file system. Loads all database images into files.