开发者

Which image file formats for upload validation?

I'm setting up image upload validations for paperclip (so someone doesnt upload a pdf, etc...), and I'm curious about which im开发者_如何学Cage file formats should be allowed for upload?

I've noticed in various examples, that some validations only allow .jpg, .gif, and .png. Is there an underlying reason to this? I believe there are a lot more albeit less popular formats out there.


There are a huge number of image formats. Most can't be viewed in a browser so there are few reasons why you'd want to allow those for most web sites.

Image formats like .tiff, .raw and the proprietary variants can be huge and are most appropriate for high-resolution uses, like photographic printing, so you probably don't want to use them. They're too unwieldy.

.jpg, .gif and .png are the usual choices for web use because they can compress down to small sizes allowing fast movement from the server to the browser. .jpg at the higher-quality/lower-compression settings can be pretty good quality too and works well for photograph-type images where there are not large areas of solid colors. .gif and .png are better for graphics like charts or diagrams, where there are large solid-color areas.

Wikipedia has a article talking about the various formats.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜