Skip to main content
gamedev.net
🔒 Locked

PNG file processing

Started by MasterWorks Jun 26, 2004 at 2:56 AM 7 replies 1.5k views
Original Post
MasterWorks
MasterWorks
Hi all, I have a question about batch processing PNG files. As you all know, PNG files are extremely useful because of their lossless compression with alpha. First, I use POV-RAY to render 3D image sequences to PNG format, which works great. But they often require retouching in Photoshop, for instance adjusting the color balance or levels histogram. I use Photoshop 6.0 for this because the Actions/Batch combination is so powerful. Unfortunately there are two problems - 1.) the animation gets jerky because Photoshop automatically recenters each frame of animation if there are extra transparent pixels around it, and 2.) Photoshop writes the PNG file incorrectly. For every pixel that has alpha = 0, Photoshop writes rgb = <255,255,255>, which is ridiculous. It causes horribly visible artifacts in Direct3D because the filtering algorithms interpolate all four pixel components... and, I've heard that Photoshop doesn't compress PNG files to the extent that is possible. Any ideas for how to process these images without buying a newer version of Photoshop (which I would hope doesn't have these problems?) Right now my solution is limited to drawing a 1% opaque layer of all black or whatever behind the original image and then merging visible... which is a lame hack! (Obviously I could work on getting better renderings, but sometimes you just need to do 2D manipulation on the images and nothing else will do.) -Jay
Kwizatz
Kwizatz
Try ImageMagic is command line, but that makes it perfect for batch processing, for example I wrote a small Perl script to generate 100x100 pixel PNG thumbnails from all jpg located in the current directory, I also use it from within PHP to generate the thumbnails for the screenshots I have at Full Panic Day.

Have fun! :)
danbrown
danbrown
Quote:
Original post by Kwizatz
Try ImageMagic is command line, but that makes it perfect for batch processing, for example I wrote a small Perl script to generate 100x100 pixel PNG thumbnails from all jpg located in the current directory, I also use it from within PHP to generate the thumbnails for the screenshots I have at Full Panic Day.

Have fun! :)


PHP can open an image, resize it with bilinear filtering and save it as a different file in about 15 lines of code, why would you use a seperate program? I use it for a photo gallery system I'm writing when new pics are uploaded.

Dan
Dan
Etnu
Etnu
That's pretty retarded if PS does that. I use Paint shop pro and it doesn't seem to have any issue writing alpha values properly.

*shrug*
---------------------------Hello, and Welcome to some arbitrary temporal location in the space-time continuum.
Kwizatz
Kwizatz
Quote:
Original post by danbrown
PHP can open an image, resize it with bilinear filtering and save it as a different file in about 15 lines of code, why would you use a seperate program? I use it for a photo gallery system I'm writing when new pics are uploaded.

Dan


Well, for one thing I already had the Perl script handy, not sure if PHP does it out of the box or if you have to enable the functionality like if you were to use CURL, and it only takes a line do it with exec:

$OutPut = exec("convert -geometry 100x100 -antialias -quality 60 -depth 8 -colors 256 ".$_FILES['newimage']['tmp_name']." $destination_thumbnail");

perhaps not the safest code though.

Also I guess I didn't quite looked so hard for PHP functions for image manipulation :)

Cheers!
MasterWorks
MasterWorks
Does Paint Shop Pro have a batch processing feature that will allow me to perform the same actions on a large (90+) number of PNG files?

And I would "use a different program" because I don't need to do image resizing. That's the one thing I DON'T need to do. I DO need to perform levels adjustments, color calibration, and possibly use some filters. Adjusting the levels histogram is so important for creating good images, and sharpen/adjust contrast do not have the same results.
Kwizatz
Kwizatz
Changing size is one of the many features Image Magik has, remove the argument "-geometry 100x100" from the above example and you'll be converting the image to an antialiazed 60% quality compresion 8 bit 256 color palette PNG image, no size change, in my case I needed to create thumbnails, so I used the sizing options, anyway its your decition of course, the program is free if you decide to give it a try :).

Cheers!
MasterWorks
MasterWorks
I appreciate the reponses, however I need pretty sophisticated image editing abilities; the batch processing doesn't do me any good if it can't perform brightness levels histogram adjustment.

Its too bad Photoshop 6.0 doesn't work correctly on PNG files... perhaps the newest Photoshop is the only answer? Does anyboy know for sure if this would address my problems? I know SOMEBODY has seen the stupid white fringes I'm talking about on their D3DX-loaded PNG files saved with Photoshop...
JoeCoder
JoeCoder
I don't know if the latest version of photoshop will help you, but Paint Shop Pro 8 has excellent batch processing abilities. I haven't spent much time in imageready, but PSP8 also has excellent preview tools for saving images in different formats with varying amounts of compression. I use PNG with alpha maps in my engine (Loaded via the FreeImage Lib) and it works great.
------------------------------yage3d.net—a free 3D game engine written in D.listpod.net—a community powered web 2.0 site of lists.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.