On Jul 19, 8:14 pm, Pe?a, Botp <b... / delmonte-phil.com> wrote:
> From: Daniel Berger [mailto:djber... / gmail.com]
> # require 'ptools'
> # File.image?(file)
>
> i like the image routines, but could it be made extendible? maybe a template where we can add file info/properties easily like..
>
> >cat /temp/image_template
>
> bmp          BM6
> jpg,jpeg     \377\330\377\340\000\020JFIF
> png          \211PNG
> gif          GIF89a
> gif          GIF97a
> ....

I'd rather not. Based on the information I read, those templates don't
change (for the file formats I support anyway). I'm not sure what the
point would be, and it would be more work that I want to avoid. :)

> i've updated my ptools to 1.5 and am looking at ptools.rb. but i have concern, are you sure you like to add those extra methods like .jpg? .png?, etc?

They're private.

> i find too many methods already in ruby. You have already image?, would it be ok  if image? return the image type like "jpg" eg, and nil if it's not? like,
>
> File.image?("test.jpg") => "jpg"

But, the '?' indicates a boolean method. I'd rather not.

> also, image? should not be extension dependent since i rename some files here =)

True, but the method I implemented is meant as a poor man's
replacement for filemagic, to deal with the more likely and common
cases. I want to keep it simple. If you want a more robust and
technically more accurate way to detect images, use filemagic
instead. :)

Regards,

Dan