Skip to content

Instantly share code, notes, and snippets.

@somebox
Created November 25, 2009 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save somebox/242716 to your computer and use it in GitHub Desktop.
Save somebox/242716 to your computer and use it in GitHub Desktop.
# Use spawn to fork the resize.
# you'll want to have the following lines in environment.rb:
# Spawn::method :fork, 'production'
# Spawn::method :yield, 'test'
def downsample!(quality=DEFAULT_QUALITY)
id = spawn do
image = Magick::ImageList.new(self.absolute_filename)
image.write("jpeg:#{self.absolute_filename}") {self.quality = quality}
end
wait(id)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment