ImageOptim breaks png files - image-compression

I would like to compress png files on my site. I found ImageOptim program. For jpeg files it works great, but when I compressed png files it displayed incorrectly on the site (part of the picture is cut off).
My question is how to make it work in browsers? I see that ImageOptim uses several tools for png compressing(PNGOUT,OPTIpng etc).Maybe I should set some specific tool?

I recommend using JPEG & PNG Stripper.
You can either drag and drop your image files to the GUI or use it as a command line tool.

Related

Use PNG or JPG for iPhone images downloaded from server

I realize that PNG is normally the web standard, but I might have a bit of a unique situation. I'm building an app that downloads lots of images from a server. The download needs to be as quick as possible, especially over 3G connections. I've been looking into the best compression for the images on the server. Ideally, every image I use can be quickly resized for the app using a drag and drop converter of some sort. When I convert one of the images to a PNG, the file size is around 130KB. When converted to an acceptable JPG quality however, the file size comes in at well under 50KB. Should I use JPGs in the application?
Thanks in advance,
It actually depends on the type of images.
The basic rule is to use JPEG for photos and PNG for everything else.
Why is it so?
JPEG compression is designed for photos - photos can handle lossy compression. On the other hand, PNG is compression designed for images which have similar pixels close to each other (straight lines, areas filled with one color, texts, etc.). If you try to use JPEG on an image which is not a photo, you'll be surprised - it won't look very good.
PNG is a standard - but for icons, backgrounds, patterns etc; not for photos.
Yes you can use jpg. You will not encounter any problem. It is a tradeoff between quality and size. Jpeg is usually smaller because it is compressed so as to reduce size. Png is lossless compressed.
I have made applications that use both png and jpeg and they both work like a charm.
EDIT: You can also check out this link PNG vs JPEG
PNG images are huge in size, use JPG as long as it's possible (when you don't need transparency)

How can I use tesseract from command line to read inside an opened window?

I'm trying to use tesseract from command line to run OCR on the content of an opened window. In particular I'm willing to read the text typed into a current opened Notepad window.
I've read the documentation and the wiki here: http://code.google.com/p/tesseract-ocr/w/list
but I didn't find anything that helped me in this project, further more I've also searched here for similar questions ( there are many about OCR) but nothing seems to work/ be applicable in my case.
Is it feasible?
I'm mainly a PHP coder (coding just for fun) and have no experience in non-web languages.
Thanks in advance.
Tesseract is designed to take a TIFF image as input and know nothing about the Windows or screen Device Contexts. So you would need to add code to locate the windows handle for the Notepad window , perform a screen capture and clip the window based on the current window size reported by Windows and save the resulting image to a file. This image will most likely be black and white which will make it easier to OCR as I suspect Tesseract 2.0 only works with B/W Images. The next problem will be Tesseract gving poor results due to the low DPI (resolution) of the source image.
To evaluate the suitability of your approach I would perform some manual tests by opening Notepad, taking screenshots, opening the screenshots in MSPaint, clipping the text you want to OCR, save the clipped image to a TIFF or BMP and send this file to Tesseract. This could save you a lot of time and effort if the results are not as good as you need or expect.

web loadable 80x80 thumbnail images - best format choice if compression is done on the server

I've read many of the png vs. jpg threads here and elsewhere. I didn't find this aspect covered for small images that are downloaded from a server.
A short recap:
Xcode optimizes png images that are delivered with the app bundle in a way that they are optimized for the iOS hardware ("png magic")
png images support transparency (which I don't need)
png is the better choice from graphics, jpg for pictures (we have pictures)
I'm building an app that periodically downloads feeds that contain links to thumbnail images (size 80x80). These images are presented side by side the text content in a tableview. I can influence which format is used (jpg, png) on the server side.
If I use an uncompressed png format, it will have about 17k size for one image. This is quite large. And since this png doesn't use the "png magic" of Xcode, the iPhone still might need quite some cpu to get them into the table view compared to an "Xcode prepared" png.
The same image as a compressed jpg is only 3k which is great.
Question: are there lab comparisons that show the real world performance of these 2 formats?
Another one: has anyone used jpgs of a similar size (80x80, 3k) successfully in a table-view?
Many thanks in advance
What do you mean "lab comparisons"? PNG is going to do better with flat colors -- it uses variations on run-length and dictionary encoding as I understand. JPEG will be better with images containing subtle gradients, and loses data mostly in jumps in luminosity which are hard for the human eye to see. "Better" here refers only to file size. It sounds like you would want JPEGs here.

Default-Portrait.png for iPad: any way to make the file size smaller?

I'm making a Universal App using MonoTouch, and I'm adding my Default-Portrait.png file. That file alone (a 768x1004 .png file) is adding 711k to the size of the app. My app itself is only about 7 megs, so it's adding 10% just for the splash screen.
I could easily make this thing an 80k jpg file instead of a png, but the device doesn't seem to look for a .jpg file. Does anyone have tips for reducing the size of this launch art?
At this point, I'm thinking I might just leave the launch art out and load my own jpg and display it as soon as I have the ability to. That'll keep my app size down, but it's not as nice as having the launch art scale in immediately like most apps do.
Hmmm...given the screen of the iPad and the visual quality users are expecting, I'd just leave it like that.
But if you do want to reduce the disk space, try going to Project > Edit Project Settings > Build (tab at top), and searching for a parameter called "Compress PNG Files." Make sure that's checked. It'll run the pngcrush utility before loading the file onto disk (check the size of your IPA archive after to see if it had any effect).
pngcrush is nice as well, however that will not reduce the quality of you image. If reducing the quality of the image is an option for you, then you might try this tool: http://www.punypng.com/ - or just use an image editing tool to "optimize" the image ...
I recommend pngout if you want to really squeeze those PNGs down, and this won't cost you any quality. It simply removes unnecessary metadata (like pngcrush) and uses its own compression algorithm which is compatible with the regular decompressor used in PNG (zlib). It's really slow, though.
A simpler option is to try "Save for web" in your image manipulation program of choice. Exporting from Acorn (not just the regular save) sometimes gives me vastly smaller files. This is especially true for default images which have large, uniform areas in one colour (screenshots, a small logo in the middle of a black screen).
Is there any reason why you want to reduce the file size that badly? I don't think it matters in your case. I just checked 3 of my apps and the Default.png (of various portrait/landscape varieties) is between 29KB and 422KB, so whilst yours do seem a little heavy, your still way under the 3G download limit.
Are you positive it's adding that much to the size of the app? Did you compare a before and after?
Xcode uses pngcrush on the images for you. I know because I just tried to substitue jpegs for pngs and got the following result:
So, in short, there's not a lot to be done except simplify the image beforehand. Xcode will handle the rest.

Skipping the 'CompressResources' build step for Xcode iPhone apps

Is it possible to set an iPhone Xcode project to skip the 'CompressResources' build step?
Specifically, I want to skip the stage where it runs pngcrush on all of my .png files, many of which don't survive the experience in a form which my app can read.
Edit: the version of pngcrush used creates png files which contain a non-standard 'mandatory, private' chunk which explicitly prevents decoding. I've modified my png reader to handle these files, but I'd still like a per-project method of skipping this step. One of the other side effects of pngcrush is that it doesn't save the colour value of transparent pixels, so alpha-ed textures show fringing at smaller mip levels.
The iphone png format is described here: https://web.archive.org/web/20110519164905/http://modmyi.com/wiki/index.php/Iphone_PNG_images. In short,
Skip the CgBI chunk
Skip the zlib headers
Swap BGR to RGB channel order
Edit: It appears it also premultiplies the alpha, so:
Divide by alpha
You can add "IPHONE_OPTIMIZE_OPTIONS=-skip-PNGs" to your project settings to prevent the png mangling, but be careful with it, you might need to optimize the icon and Default.png separately then.
The iphoneos-optimize script converts PNG files into a nonstandard format that is optimized for display on the iPhone. The script will convert any files with the png extension that it finds inside your app bundle.
I had a similar problem, and solved it by giving my file the extension _png (i.e., prefixed an underscore). iphoneos-optimize ignored it and left it a regular PNG file. If you can deal with it that way, it's probably a lot safer than mucking about with the build scripts.
Open build settings
Under "packaging" choose Compress PNG files
Choose "NO"
If you look at the build output you'll see that the CompressResources step runs the script /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/iphoneos-optimize. This appears to be just a shell script that runs pngcrush and compiles plists into binary format. You could probably modify this script to not run pngcrush.
Note that someone in this thread noticed that if they did not run their icon file through pngcrush it wasn't showing up on the phone.
Interestingly, the version of pngcrush in the directory of the script has a -iphone argument. Anybody know if this is standard or something Apple just ships with their build of it?
That might be another issue all together. In many cases the problem has to do with naming and can be solved very easily.
read this:
http://cocoapi.wordpress.com/2009/03/22/iphone-images-not-appearing-in-real-iphone-this-is-why/