Title: Compress manually
Last modified: July 22, 2023

---

# Compress manually

 *  Resolved [enkirch](https://wordpress.org/support/users/enkirch/)
 * (@enkirch)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/compress-manually/)
 * Hi,
   Users can upload images to our site. A function then creates several image
   formats from the image.
 * The question I have is, at that moment I know the image path with all the images.
 * Could I somehow then say, with an API call or similar, please optimise these 
   images into folders?
 * That way I could avoid scanning and being “overwhelmed”.
 * By overwhelmed I mean I have, for example, a year/month folder, let’s call it“
   2023/03”. There are 3000 folders in there. Each folder can contain up to 50 images.
 * If I now run the mass optimiser only on the March folder, it returns about 200
   images as a result. After I have finished optimising, I scan again and it gives
   me 300 pictures again.
 * Instead of giving me all the images that have not yet been optimised.
 * At the beginning, when I started with the March folder, it still found 20000 
   images as a result. These small batches of images only seem to appear towards
   the end.

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Author [Shane Bishop](https://wordpress.org/support/users/nosilver4u/)
 * (@nosilver4u)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/compress-manually/#post-16919895)
 * Certainly, you could run the core ewww_image_optimizer() function once you have
   the path and are done with any modifications:
 *     ```wp-block-code
       if ( function_exists( 'ewww_image_optimizer' ) ) {
           ewww_image_optimizer( $path );
       }
       ```
   
 *  Thread Starter [enkirch](https://wordpress.org/support/users/enkirch/)
 * (@enkirch)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/compress-manually/#post-16920630)
 * That sounds good.
 * Is the following also guaranteed with the call
    - Check if the images have already been compressed to prevent double compression
    - At the moment when I create several small image formats from the original 
      images, it can also happen that I do this for several customers. If I now 
      process 2 customers, I would also have to call the function twice with different
      paths. is this a problem? Because in the moment also then the database with
      the already optimized images would have to be loaded, by the 2 calls.
 * I have also briefly looked at the function. the description says
 * [@param](https://wordpress.org/support/users/param/) string $file Full absolute
   path to the image file.
 * Can I now not store a folder path there? But must specify the path directly to
   the file?
    -  This reply was modified 2 years, 10 months ago by [enkirch](https://wordpress.org/support/users/enkirch/).
 *  Plugin Author [Shane Bishop](https://wordpress.org/support/users/nosilver4u/)
 * (@nosilver4u)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/compress-manually/#post-16924999)
 * Yes, the ewww_image_optimizer() function will check if a given file/image has
   already been optimized, and it will not be a problem to call it multiple times,
   as it’s only looking up that specific image in the database. The table is properly
   indexed to minimize the performance impact of multiple lookups.
 * As for the $file param, yes it must be a file path, it does not accept a directory/
   folder.
 *  Plugin Support [adamewww](https://wordpress.org/support/users/adamewww/)
 * (@adamewww)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/compress-manually/#post-16974769)
 * Resolving this thread, however, if you have further questions, please feel free
   to start a new one!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Compress manually’ is closed to new replies.

 * ![](https://ps.w.org/ewww-image-optimizer/assets/icon-256x256.png?rev=1582276)
 * [EWWW Image Optimizer](https://wordpress.org/plugins/ewww-image-optimizer/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/ewww-image-optimizer/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/ewww-image-optimizer/)
 * [Active Topics](https://wordpress.org/support/plugin/ewww-image-optimizer/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ewww-image-optimizer/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ewww-image-optimizer/reviews/)

 * 5 replies
 * 3 participants
 * Last reply from: [adamewww](https://wordpress.org/support/users/adamewww/)
 * Last activity: [2 years, 9 months ago](https://wordpress.org/support/topic/compress-manually/#post-16974769)
 * Status: resolved