New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

manipulator

Package Overview
Dependencies
Maintainers
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

manipulator

  • 1.1.0
  • Rubygems
  • Socket score

Version published
Maintainers
2
Created
Source

= Manipulator

S3 is great for storing image files, but manipulating images after they've been saved to S3 (rotating, resizing, cropping, etc.) is a bit of a chore. Usually it goes something like this:

  • download file from S3, save to local tmp file
  • run graphics or image magick over local tmp file
  • push modified image back to S3
  • remember to clean up tmp file

After re-implementing this pattern a few times over (and filling up /tmp by forgetting the last step), we decided to roll this into a gem that makes S3 image manipulation as easy as:

m = Manipulator.new(:processor => :gm) # use GraphicsMagick; defaults to ImageMagick m.manipulate({:bucket => 'my-bucket', :key => 'some/file.jpg'}) do |img| img.rotate(90) img.resize_to_fit(75,75) end

The idea is to instantiate a Manipulator and then pass it a bucket name and key to manipulate. Manipulator will download your image to a local tmp file, then yield a MiniMagick::Image wrapping that file. Call methods on the yielded image to make modifications; as soon as the block returns, the modified image is pushed back to S3 and the tmp file is removed.

We're using MiniMagick now instead of RMagick to save memory - we found that RMagick was a hog. MiniMagick is a lot more straightforward and has a nice interface for both GraphicsMagick (recommended) and ImageMagick.

Want to do something that MiniMagick doesn't directly support, like removing all profiles from an image with GraphicsMagick (aka ImageMagick's strip method)? m.manipulate('my-bucket', 'my-key' do |img| gm mogrify +profile '*' #{manipulator.temp_file_path} end

== Install

$ gem install manipulator

== Dependencies

  • AWS/S3 (http://rubygems.org/gems/aws-s3)
  • AWSCredentials (http://rubygems.org/gems/aws_credentials)
  • MiniMagick (http://rubygems.org/gems/mini_magick)

== Future

  • Allow images to be manipulated from other sources (FTP, HTTP, etc.)

== Copyright

Copyright (c) 2010 The New York Times Company. See LICENSE for details.

FAQs

Package last updated on 02 Dec 2010

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc