开发者

Optimizing TIF and EPS files with PHP

Are there any PHP libraries out there that will reduce the size of an EPS or TIF file? Or create one with a reduced size in the first place?

I have seen some sites that have automated TIF and EPS generation and produce significantly smaller file sizes than I can and their quality is the same (to my eye anyway).

I have tried with ImageMagick on the Linux command line but it doesn't appear to have any specific optimize ability for these formats.

Thanks for any help you folks can offer.

Edit:

I'm trying to optimize someone else's code and haven't used ImageMagick before so am learning it as I go. @Dagon, are you sure it doesn't have TIF support built in? I could totally be misunderstanding things but it appears 开发者_C百科to convert JPG's to TIF's as is. But you're definitely right about EPS, I see now that the code is using InkScape to create the EPS files.

Anyway, I have found if I tell it to use the ZIP compression a TIF's file size it is reduced significantly. Example: convert mypic.jpg -compress zip mypic.tif

Does anyone have any idea if there are drawbacks to doing this? The program is a bar code image creator so there's not a lot of image data I'm worried about losing as the images are quite basic. They're coming out clean looking which is what matters to me.

As for the EPS files, it appears the EPS generated by another site is done so with a different program than Inkscape. Their EPS generator is specifically made for bar codes. I don't know much about the EPS format, but it appears they make theirs significantly smaller by defining a few rules at the top since they know what they're making every time. Where as Inkscape keeps things vague since it could be used to make any kind of vector.

So I guess I have found my answers. If anyone has anything to add or point out what I have dead wrong it's still appreciated.

Thanks!


Re: tiff, There may be drawbacks such as lack of zip support in certain software you need to use the final product in, but other than that, no there are no drawbacks. Zip is a lossless compression and you lose no data or quality by doing this. Jpeg compression which is lossy and can mess up images is also supported in TIFF files (at least photoshop and acrobat support it). However I expect that barcodes can stand to be compressed quite heavily.

For barcode, an obvious optimization for tiff is greyscale instead of RGB. You will reduce the file size by about a 3rd. And bitmap (black or white) would be about 1/10th the size of grey. (very rough numbers: 1000pixel square in photoshop, white only: rgb 2.8MB; grey .9MB; bitmap: .1MB)

EPS files are often vector images which, in very basic terms, stores the math to redraw the image. In the domain of barcodes, this could result in very small files.

And yes, as mentioned elsewhere here, for PHP, consider JPG or PNG which have PHP GD support.


ImageMagick dose not have native support for theses formats, you would have to install a third party app, and call it from the command line.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜