size in the image name?

10 views
Skip to first unread message

Devi

unread,
Mar 28, 2013, 11:30:51 PM3/28/13
to hasgeek-code
Currently, the url for an image with a different resolution is
/<image_id>?size=<width>x<height>, which doesn't look nice, IMO.
How about /<image_id>-w<width>-h<height>.<extn>? Here width, height
and extn could be optional.

We can store the images with the name in the above format so that we
don't need the Thumbnail table [1] which just stores the size info and
the map to original image name. This way, cleaning up the local cache
of images wouldn't involve any db access and can be a simple cron job
which only preserves last recently accessed images.

[1]: https://github.com/hasgeek/imgee/blob/master/imgee/models/thumbnail.py

Kiran Jonnalagadda

unread,
Mar 30, 2013, 11:20:35 PM3/30/13
to HasGeek Code

Devi, we don't want to serve locally. These URLs are image generators that do a 301 redirect to the permanent URL, which is currently on S3 but may be on a CDN.

Any of these URL formats works for me:

/file/<name> (original file)
/file/<name>?size=123
/file/<name>?size=123x456
/file/<name>?x=123&y=456
/file/<name>/123
/file/<name>/123x456

Single numbers imply the same value on both x and y axis.

We could have another endpoint /thumbnail/<name> that fits the image to the box along the smaller side and then crops the rest. This effect is used in photo galleries: Flickr and Twitter use it to get square thumbnails for photos and avatar images.

There is no image extension on these URLs because they are redirectors to the actual image files, which will have extensions.

Kiran

--
Kiran Jonnalagadda
+91-99452-35123
http://hasgeek.com/

(Sent from my phone)

--
You received this message because you are subscribed to the Google Groups "HasGeek Code" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hasgeek-code...@googlegroups.com.
To post to this group, send email to hasgee...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Anand Chitipothu

unread,
Mar 31, 2013, 9:35:51 AM3/31/13
to hasgee...@googlegroups.com
On Sun, Mar 31, 2013 at 8:50 AM, Kiran Jonnalagadda <ki...@hasgeek.com> wrote:
> Devi, we don't want to serve locally. These URLs are image generators that
> do a 301 redirect to the permanent URL, which is currently on S3 but may be
> on a CDN.

I see a problem with this approach.

I can maliciously try to request for a the same image for million
different sizes and cause fat s3 bill to you. Unless you've fixed
sizes, I don't think it is good idea to store resized images on s3.

>
> Any of these URL formats works for me:
>
> /file/<name> (original file)
> /file/<name>?size=123
> /file/<name>?size=123x456
> /file/<name>?x=123&y=456
> /file/<name>/123
> /file/<name>/123x456
>
> Single numbers imply the same value on both x and y axis.

Sometimes the design want to add a constraint on width and someones on
the height. I think there should be a way to only specify either width
or height. They other dimension can be computed from the original
image from the aspect ratio.

> We could have another endpoint /thumbnail/<name> that fits the image to the
> box along the smaller side and then crops the rest. This effect is used in
> photo galleries: Flickr and Twitter use it to get square thumbnails for
> photos and avatar images.

Does it mean the aspect ratio is alway maintained and whatever doesn't
fit in the given box gets cropped?

> There is no image extension on these URLs because they are redirectors to
> the actual image files, which will have extensions.

I think it is useful to have extension in the URL. As a user, it is
very irritating when I download an image and that doesn't have an
extension.

Anand

Noufal Ibrahim

unread,
Mar 31, 2013, 10:55:42 AM3/31/13
to Anand Chitipothu, hasgee...@googlegroups.com
Anand Chitipothu <anand...@gmail.com> writes:


[...]

>> There is no image extension on these URLs because they are redirectors to
>> the actual image files, which will have extensions.
>
> I think it is useful to have extension in the URL. As a user, it is
> very irritating when I download an image and that doesn't have an
> extension.
[...]

Doesn't a content-disposition header help in this case to give the
downloaded asset a decent file name.

--
Cordially,
Noufal
http://nibrahim.net.in

Kiran Jonnalagadda

unread,
Apr 1, 2013, 3:17:55 AM4/1/13
to HasGeek Code
On Sun, Mar 31, 2013 at 7:05 PM, Anand Chitipothu <anand...@gmail.com> wrote:
I see a problem with this approach.

I can maliciously try to request for a the same image for million
different sizes and cause fat s3 bill to you. Unless you've fixed
sizes, I don't think it is good idea to store resized images on s3.

We can apply rate limits if this happens. This isn't very different from a DoS attack.
 
Sometimes the design want to add a constraint on width and someones on
the height. I think there should be a way to only specify either width
or height. They other dimension can be computed from the original
image from the aspect ratio.

I guess the endpoints can accept a size of "0" to indicate automatic sizing.
 
Does it mean the aspect ratio is alway maintained and whatever doesn't
fit in the given box gets cropped?

Yes.
 
I think it is useful to have extension in the URL. As a user, it is
very irritating when I download an image and that doesn't have an
extension.

Don't forget it's a 301 redirect. The browser will show the user the final URL, which will have an extension.

Kiran

Anand Chitipothu

unread,
Apr 1, 2013, 3:30:54 AM4/1/13
to hasgee...@googlegroups.com
>>
>> I think it is useful to have extension in the URL. As a user, it is
>> very irritating when I download an image and that doesn't have an
>> extension.
>
>
> Don't forget it's a 301 redirect. The browser will show the user the final
> URL, which will have an extension.

Isn't it bad to make 2 requests for fetching each image? Wouldn't it
increase the page load time?

Anand

Kiran Jonnalagadda

unread,
Apr 2, 2013, 2:42:34 AM4/2/13
to hasgee...@googlegroups.com
Anand, that's up to the developer/designer of the final page. They can either use the imgee redirector URL or the final S3 URL.

Kiran

-- 
Kiran Jonnalagadda

Reply all
Reply to author
Forward
0 new messages