Jump to content

Automatic photo compression software?


Recommended Posts

Posted

Does anyone know of any software that will scour folders I select for large JPG files and reduce them in size, we've got these lovely 20mp classroom cameras but they make some huge files, now I could go through all of the settings on the cameras and set them to shoot at a lower mp but that doesn't help with the ones already clogging up my servers.

 

Does anyone know of any software that can do the job? Has to be offline as there are pictures of the kids and I don't want the nightmare of explaining why I've used an online service to do it.

 

Ideally I'd like something that does with JPG's what Adobe media encode can do with videos and have watch folders to automatically compress the photos as and when they are put on the server.

Posted
Another possible would be "Total Image Converter". Certainly good for squashing whole folders of images, also creates a thumbnail as it goes. Don't know about automation though.
  • Thanks 1
Posted (edited)

XnView is good. You can do a filtered search across all your folders and then queue up the images you find and do a batch proccess to compress them all.

 

Edit:There is a feature for the enchanced version XnViewMP called 'hot folders' that i think might satisfy your requirement for compressing a watched folder. Just tested it and as soon as I placed the jpg in the hotfolder it was replaced with a compressed version at my specified compression ratio and resolution.

Edited by ollyyllo
  • Thanks 1
Posted
Could probably convert my https://github.com/mavhc/shrink-video-recursive-python to do photos instead of videos

 

I could have sworn I saw a news article a couple of days ago about a snazzy new JPEG compression library, but a Google search now didn't turn it up. It did turn up a number of different JPEG compression libraries, though, with various space-savings claims for each of them. Could be something to look at using in an image compression tool.

  • 9 months later...
Posted (edited)

FastStone Image resizer does recursive subfolder resizing and other options such as watermarking or cropping.

 

Very good but found that if you don't double check the options it will not delete the original and simply create another copy of the jpg which is compressed.

 

Will look into XnView to see if that works better.

 

Just tried mass image Compressor but it changes the modified date attributes and crashed on me! Not as advanced at all.

Edited by Alis_Klar
Posted

We have fsrm quotas on student home drives (the only place they can save to), when they max it out with photos and come to us for more space we send them back and tell them to resize them themselves. We have also asked the photography teacher to teach resizeing and taking images of appropriate size for their use as part of the photography course.

 

We have Flexxi resizer on all the machines (actually just a link the program is hosted on a share) to allow students to bulk resize (is free and fairly simple to use), although for some reason it has pictures of a fox all over it.

Posted

Have you considered using a scripting language for this? It means it can be automated easily and customised at will. Here is something in powershell I through together, it provides full customisable and high quality resizes:

There's probably room for improvement, logging, backup of original files and some error handling, but the hard work is done.

 

[system.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
$searchRoot = "c:\test"
$ignoreFilesSmallerThan = 1MB
$maxImageWidth = 1920
$maxImageHeight = 1920
$maxResolution = 72
$saveQuality = 100

$encoder = [system.Drawing.Imaging.ImageCodecInfo]::GetImageEncoders() | Where-Object { $_.FormatID -eq [system.Drawing.Imaging.ImageFormat]::Jpeg.Guid }
$encodingParams = New-Object System.Drawing.Imaging.EncoderParameters
$encodingParams.Param = @(New-Object System.Drawing.Imaging.EncoderParameter -ArgumentList @([system.Drawing.Imaging.Encoder]::Quality, $saveQuality))

$files = Get-ChildItem -Path $searchRoot -Filter *.jpg -Recurse | Where-Object { $_.Length -gt $ignoreFilesSmallerThan }

foreach ($file in $files)
{
   $sourceBytes = [system.IO.File]::ReadAllBytes($file.FullName)
   $sourceStream = New-Object System.IO.MemoryStream
   $sourceStream.Write($sourceBytes, 0, $sourceBytes.Length)
   $sourceImage = [system.Drawing.Bitmap]::FromStream($sourceStream)

   if ($sourceImage.Width -gt $maxImageWidth)
   {
       $newWidth = $sourceImage.Width
       $newHeight = $sourceImage.Height
       $newResolution = $sourceImage.HorizontalResolution

       if ($newWidth -gt $maxImageWidth)
       {
           $newHeight = [Math]::Floor(($maxImageWidth / $sourceImage.Width) * $sourceImage.Height)
           $newWidth = $maxImageWidth
       }

       if ($newHeight -gt $maxImageHeight)
       {
           $newWidth = [Math]::Floor(($maxImageHeight / $sourceImage.Height) * $sourceImage.Width)
           $newHeight = $maxImageHeight
       }

       if ($sourceImage.HorizontalResolution -gt $maxResolution)
       {
           $newResolution = $maxResolution
       }

       Write-Output "$newWidth $newHeight"

       $destRect = New-Object -TypeName System.Drawing.Rectangle -ArgumentList @(0, 0, $newWidth, $newHeight)
       $destImage = New-Object -TypeName System.Drawing.Bitmap -ArgumentList @($destRect.Width, $destRect.Height)
       $destImage.SetResolution($newResolution, $newResolution);

       $wrapMode = New-Object -TypeName System.Drawing.Imaging.ImageAttributes
       $wrapMode.SetWrapMode([system.Drawing.Drawing2D.WrapMode]::TileFlipXY)
       $graphics = [system.Drawing.Graphics]::FromImage($destImage)
       $graphics.CompositingMode = [system.Drawing.Drawing2D.CompositingMode]::SourceCopy
       $graphics.CompositingQuality = [system.Drawing.Drawing2D.CompositingQuality]::HighQuality
       $graphics.InterpolationMode = [system.Drawing.Drawing2D.InterpolationMode]::HighQualityBicubic
       $graphics.SmoothingMode = [system.Drawing.Drawing2D.SmoothingMode]::HighQuality
       $graphics.PixelOffsetMode = [system.Drawing.Drawing2D.PixelOffsetMode]::HighQuality
       $graphics.DrawImage($sourceImage, $destRect, 0, 0, $sourceImage.Width, $sourceImage.Height, [system.Drawing.GraphicsUnit]::Pixel, $wrapMode)
       $graphics.Dispose()
       $wrapmode.Dispose()

       $destImage.Save($file.FullName, $encoder, $encodingParams)
       $destImage.Dispose()
   }
   $sourceStream.Dispose()
   $sourceImage.Dispose()
}

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...