> John Joyce wrote:
>> Cool, Dan, that looks pretty slick. I certainly couldn't have done
>> that so quickly, but I knew what basically was needed. That looks
>> like about what I was thinking of conceptually. Very nice and
>> clean code! Nice touch with downcasing file extensions too! I hate
>> that cameras all like to upcase filenames... (> <)!
>> That will probably run a lot lighter than RMagick methods, I'll
>> try it out later. I've been fiddling with the RMagick API all
>> afternoon. There's a lot of documentation but some of it is
>> lacking in clear examples.
>> At this point I know how to scale images and keep the aspect ratio
>> within a maximum new size, but I'd like to have the final output
>> be square with matting on the sides for portrait orientation,
>> matting on the top and bottom for landscape orientation, either
>> one with the scaled image centered.
>> Will this require subsequent compositing after scaling? Or did I
>> miss a method somewhere in the docs that does all of this at once?
>> John Joyce
> Yes, you'll need to composite the scaled image on top of the
> background of your desired size. See my article "Alpha Compositing
> - Part 1" [http://rmagick.rubyforge.org/src_over.html\]. If you're
> making a lot of thumbnails you might also be interested in "Making
> Thumbnails with RMagick" [http://rmagick.rubyforge.org/resizing-
> methods.html], which compares the performance of all the RMagick
> resizing methods.
> Also if you'll tell me which parts of the documentation are lacking
> in clear examples I'll see what I can do to fix it. You can always
> open a documentation bug in the RMagick bug tracker on RubyForge.
Also very cool. Thanks.
I will check that stuff out.
I guess it's just a bit much the first time looking at the API.
The main thing I found a bit vague was creating a new Image or
ImageList instance.
ImageList responds basically as I would expect, but Image doesn't .
Initially I was trying:
img = Image.read('redzigzag.jpg')
Which apparently creates something similar to ImageList.
But when trying to use Image methods, I kept getting an error
about ...private method ... called for ....[...]:array
(the elipses are just leaving out specifics)
What I didn't realize I was missing was the [0] in:
img = Image.read('redzigzag.jpg')[0]
I'm still not quite sure how that is working as part of that
statement really, but I know how to get it going anyway.
Because the file can contain multiple images (say, in the case of an
animated GIF or a multi-layer Photoshop image), the Image.read method
returns an array with an element for each image in the file. By adding
[0] you're simply saying "the first image in the array."
Perhaps I need to emphasize this more in the doc. I'll see what I can
do.
I can certainly see the convenience of using ImageList to batch a
bunch of images, but I figured that Image was fine for working out
the logic and flow of what I want to do first.
There's a lot of overlap between ImageList and Image. ImageList is
good if you're working with animations or layers, otherwise it doesn't
offer much. I hardly ever use it. I've often thought it would've been
smarter to just have one class, named Image but with the properties of
ImageList, but that's water under the dam.
The only other truly confusing thing was lack of examples in many
method definitions. This is just me, I can "get it" faster when I
have a method definition and example with dummy data plugged in.
So do I. In fact, there are some who say that RMagick already has too
many examples, especially when they're waiting for them to run during
the install.
I look at every method to see whether it really needs
its own example, or whether it's sufficiently similar to other methods
that someone with reasonable familiarity with RMagick can figure out
how to use it. Of course I can be wrong. Again, if you have a list of
methods that you think need an example, let me know.
BTW, the RVG stuff looks pretty interesting. I didn't have time to
really dig deep into that so much, just skimming.
Overall, I especially like the simplicity of reading and writing
files with RMagick. I'm just glad I can do it with Ruby instead of
PHP, because Ruby is much easier for me to get a clear picture in my
mind of what I'm looking at.
Thanks for taking the time to post your impressions. If you're really
interested in RMagick, there are a number of books that include
tutorials or recipes. I've posted their names on the RMagick home
page. Hal Fulton's _The_Ruby_Way_ is particularly thorough.
I hope you enjoy using RMagick!
···
On Jul 18, 9:47 pm, John Joyce <dangerwillrobinsondan...@gmail.com> wrote:
On Jul 18, 2007, at 7:28 PM, Tim Hunter wrote: