Compass function to return Image Dimensions

4 views
Skip to first unread message

Richard Aday

unread,
Jan 19, 2010, 4:52:55 PM1/19/10
to compas...@googlegroups.com
Is there something like image_url() that can return the height or width of an image?

This functionality could allow us to make our CSS even more flexible regardless of whatever image size is used.

--
-Richard Aday

Chris Eppstein

unread,
Jan 19, 2010, 4:56:08 PM1/19/10
to compas...@googlegroups.com
Nope. That would be awesome, but it can't introduce any dependencies to compass.

--
You received this message because you are subscribed to the Google Groups "Compass Development" group.
To post to this group, send email to compas...@googlegroups.com.
To unsubscribe from this group, send email to compass-devs...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/compass-devs?hl=en.

Richard Aday

unread,
Jan 19, 2010, 6:38:48 PM1/19/10
to compas...@googlegroups.com
Chris,

If we don't introduce a dependency (like image science or rmagick), then the only way to do this would be to implement our own ruby code that does what those dependencies already do...

Is that really better then having a dependency?
--
-Richard Aday

Chris Eppstein

unread,
Jan 19, 2010, 6:41:52 PM1/19/10
to compas...@googlegroups.com
Yes. All images have headers that allow you to extract their size in the first few bytes. I've done it in C before. It's really not hard.

chris

Richard Aday

unread,
Jan 19, 2010, 6:43:46 PM1/19/10
to compas...@googlegroups.com
Are those headers consistent across different types of images (png, jpg, gif, etc)?

Richard Aday

unread,
Jan 19, 2010, 6:45:38 PM1/19/10
to compas...@googlegroups.com
I guess this could be a start for the Ruby code that does that:
http://snippets.dzone.com/posts/show/805
--
-Richard Aday

Chris Eppstein

unread,
Jan 19, 2010, 6:46:09 PM1/19/10
to compas...@googlegroups.com
Of course not.

Chris Eppstein

unread,
Jan 19, 2010, 7:17:36 PM1/19/10
to compas...@googlegroups.com
That's the ticket.
Reply all
Reply to author
Forward
0 new messages