Bill Jonas on Thu, 2 Aug 2001 09:10:05 -0400 |
On Thu, Aug 02, 2001 at 05:40:28AM -0400, Jeff Abrahamson wrote: > That said, if I used your (or anyone's) code verbatim, I'm sure I > would give credit, whether asked or not. It just raised my hackles a > tiny bit to read the "or anything similar" nature of your request. To be honest with you, that bit raised my eyebrows slightly as well. Anyway, a few days ago I was looking at the code. As an exercise for myself, I modified his script to use warnings and strict, and also re-wrote the dimension-sizing code. Here's what I came up with for the guts of the algorithm: if ($x > $y) { $newx = 100; $newy = int(100 * $y / $x); } elsif ($y > $x) { $newy = 100; $newx = int(100 * $x / $y); } else { $newx = $newy = 100; } ...which, IMO, is clearer in what it does. (Standard proportion formula.) Of course, Darxus' code has the advantage of not being dependent on which dimension is longer. (Although one might note that the call to "sqrt($pixelcount)" in his code is spurious and could be replaced with "$edgepixels = 100" and dividing by $edgepixels or something.) $ wc -l ~/tmp/thumbnail* 45 /home/bj/tmp/thumbnail 50 /home/bj/tmp/thumbnail.Darxus 95 total (I didn't remove any blank lines or comments, either, to get the line count down.) :) -- Bill Jonas * bill@billjonas.com * http://www.billjonas.com/ "As we enjoy great advantages from the inventions of others, we should be glad of an opportunity to serve others by any invention of ours; and this we should do freely and generously." -- Benjamin Franklin ______________________________________________________________________ Philadelphia Linux Users Group - http://www.phillylinux.org Announcements-http://lists.phillylinux.org/mail/listinfo/plug-announce General Discussion - http://lists.phillylinux.org/mail/listinfo/plug
|
|