Photo rotation

hi in my application i have a photo gallery page where i showing all my
album photos, i want to developed a functionality where i can rotate
photo there and and saved backed to file system.
how it is possible ?

RMagick can do this:
http://rmagick.rubyforge.org/

Thorsten M. wrote:

RMagick can do this:
http://rmagick.rubyforge.org/

please send me some clues i haven’t understood from rmagic
documentation.

On May 12, 6:13 am, Sunny B. [email protected]
wrote:

hi in my application i have a photo gallery page where i showing all my
album photos, i want to developed a functionality where i can rotate
photo there and and saved backed to file system.
how it is possible ?

Posted viahttp://www.ruby-forum.com/.

Untested sample code, compressed to a one-liner to get to the
essentials:

Magick::Image.read("/path/to/file/to/rotate").first.rotate!
(90).write("/path/to/rotated/file")

Breakdown and explanation:

Magick::Image.read("/path/to/your/file") -
-Read in file

.first
-select first layer (unless you are dealing with animated GIF’s or
something, this is usually the only one)

.rotate!(90)

  • I’ll let you guess. Note, unlike regular math, positive angles mean
    clockwise, not counter-clockwise. Note also the bang, which means to
    modify the object in-place, not return a new one, which is why we can
    chain these calls in one line.

.write("")

  • Write the new image out.

After doing “Magick::Image.read(”/path/to/your/file").first" you have
an Image object, which is where all the work gets done. I think you
can follow the API from there, as once you know how to get an Image
object, all the methods are right there.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs