I've got 4500+ PNG 24 images in 20+ folders that I wish to reduce the size of by converting them to PNG 8. (Aside: I've tried smushing and other png optimisations but the savings are not enough, a test of 2 folders in PS showed PNG 8 should be without significant degradation of the images)

When I tried PS CS3 Batch it wouldn't save over the originals and the new files it creates have no folder structure. Is there a way to fix this or another tool for the job?

I'm running OSX but have access to Windows XP/7.

  • What did you use to try and crunch the images? I answered a similar question oh Webmasters. I've had fantastic results with PNGs. Photoshop is absolutely awful with saving, especially if you don't use Save For Web/Devices. webmasters.stackexchange.com/questions/13/… – Bryson Apr 12 '11 at 17:44
  • Yeah I tried image ImageOptim first after seeing it mentioned on a q on stackoverflow. However I got the best overall reduction from PNGGauntlet which I used in VirtualBox Win7. XnView was also good. – Denis Hoctor Apr 13 '11 at 23:38

XnView handles batch processing/conversion. Ctrl + U : "Tools -> Batch Processing..."

  • Options to overwrite, use original path (as output), and/or keep subfolder structure.
  • Add the "Convert > Convert to Colours" transformation from the Transformations tab. One of the parameters is bits/pixel.

That's a pain isn't it? Here's the trick. After recording your actions to make it png8, click the top right corner of the actions palette and choose insert menu item. Then just click file --> save. Click OK. It should now be the last sub-item within your action.

Now when you run the batch, stuff stays in its subfolder like it's supposed to.

  • Thanks, sounds good but my attempt to implement must be wrong! I've opened a test file, created a new action, Saved for Web (PNG8), Added Save Menu Item. When I run the batch I set source to my folder and click to include subfolders. I've then tried destination as 'None' and 'Save and Close' with 'Override Action...' ticked. But I still get the files on the root of the folder not in the sub folders. – Denis Hoctor Apr 11 '11 at 1:15
  • oop, sorry, the way I did it was recording my first action as image --> mode --> 8 bits/channel. To be honest I'm not sure if that's the exact same as the save-for-web PNG8. I think it is. Test it out. – CreeDorofl Apr 11 '11 at 2:40

Install ImageMagick and run with Powershell


# Powershell script to recursively convert image formats
# Configuration
$srcfolder = "C:\test\Animals"
$destfolder = "C:\test\Animals"
#This ps1 file will add copy files to designated folder
#Do NOT use Mogrify or the original images will be deleted
$im_convert_exe = "convert.exe -density 300"
# with VECTOR files the density setting should come BEFORE the vector file
# or the image will be blurry.
# change src_filter to the format of the source files
$src_filter = "*.eps"
# change dest_ext to the format of the destination files
$dest_ext = "png"
$options = "-depth 8 -alpha off"
$logfile = "C:\temp\convert.log"
$fp = New-Item -ItemType file $logfile -force
foreach ($srcitem in $(Get-ChildItem $srcfolder -include $src_filter -recurse))
    $srcname = $srcitem.fullname

    # Construct the filename and filepath for the output
    $partial = $srcitem.FullName.Substring( $srcfolder.Length )
    $destname = $destfolder + $partial
    $destname= [System.IO.Path]::ChangeExtension( $destname , $dest_ext )
    $destpath = [System.IO.Path]::GetDirectoryName( $destname )

    # Create the destination path if it does not exist
    if (-not (test-path $destpath))
        New-Item $destpath -type directory | Out-Null

    # Perform the conversion by calling an external tool
    $cmdline =  $im_convert_exe + " `"" + $srcname  + "`"" + $options + " `"" + $destname + "`" " 
    #echo $cmdline
    invoke-expression -command $cmdline

    # Get information about the output file    
    $destitem = Get-item $destname

    # Show and record information comparing the input and output files
    $info = [string]::Format( "{0} `t {1} `t {2} `t {3} `t {4} `t {5}", $count, 
    $partial, $srcname, $destname, $srcitem.Length ,  $destitem.Length)
    echo $info
    Add-Content $fp $info




Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.