Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7544689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:44:15+00:00 2026-05-30T08:44:15+00:00

This question is the next step in my project of Optimizing a folder/directory of

  • 0

This question is the next step in my project of Optimizing a folder/directory of images and making sure not to re-optimize an image that has already been optimized without moving the optimized image to a new directory. I had a question posted here How to avoid Optimizing images that are already optimized with PHP?

My application is a Command line tool written in PHP that wraps around several Image Optimization tools and recursively scans a supplied directory and runs ALL images through the appropriate optimizer program.

Right now if I had a folder which contained 200 images and I ran my application, it would try to optimize all 200 images which is very time consuming. So say I add another 5 images to my project and I need to run the application again, it would now optimize all 205 images instead of just the 5 new images. That is the problem I am trying to solve. My idea is to have some sort of file/DB that sits in the image folders and when my application is ran, it will first read in all images that are in this file, if the image is in this file then it has already been optimized and we do not need to re-optimize it. So in my example only the 5 new images would be ran as they would not be in the file. Once completed, these 5 new images would be merged into this file so on the 3rd run of my application all 205 images would be skipped as they have already been optimized and added to the file/DB.

I think this would be a pretty good method, performance wise but I am open to all ideas for a better way or even improvements to my current idea?

Some issue though to think about, since my application runs a supplied directory recursively, if I have a folder that has 20 images and 8 other sub-folders and these all have images and some of these sub-folders have sub-folders as well, then all the images under the root supplied folder are ran, regardless of how deep it is in the hierarchy. So I am not sure if I would need to have a separate file/DB under each sub-folder that list the files processed already under each sub-folder or if 1 file/DB under the root folder would be good enough as long as it had the file path relative to the root folder.

Other thoughts are, if an image is deleted, do I need to somehow remove it from this file/DB or should I just not bother as it will likely not affect anything anyways?

My main question here, does this sound like a good solution? A file or Database type file in the image folder to list the files already optimized? If you think it is, how should I go about creating this file, should it be a simple text file with 1 image file with path on each line, or an XML file or what kind of file, PHP will likely have to read this files content into memory as an array and then when recursively scanning my directories of images it will have to compare each image it finds with this Image List array to verify if it is already in the processed list or not and then build a list of un-processed files and then process just those files

Please share your thoughts, suggestions, critism, etc, I have never done anything like this

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T08:44:16+00:00Added an answer on May 30, 2026 at 8:44 am

    It is a good idea and in general terms called cataloguing.

    Couple of things I will do is to

    • add “Last modified date” to you db table that stores Images so that If for any reason file is overwritten then it can be optimized again
    • second you dont need individual db file in each subfolder I will store possibly the directory or the path hash in th db table itself so that I know if that has been optimized or not

    Also I can do another thing which could be a overkill but manageable.

    Say you have your images in a folder lets call it “incoming” or “databucket” when you end up optimizing your images you can then move them to another folder called say “outgoing” or “filesystem” and deleting them from incoming.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is an extension / next step of this question I asked a few
This is sort of the next step of the LINQ to DB2 question I
This is next step to this question, where I need to run queries and
I have an xml file that looks like this <step> <id>3</id> <backid>1</backid> <question>Are you
This helpful idea from Andy Gaskell supports 50% of my next question: I'd like
This is a followup on the question: ASP.NET next/previous buttons to display single row
This question is about removing sequences from an array, not duplicates in the strict
I sure hope this is an ok question to ask here. I realize it
This question follows on from Assembly does not allow partially trusted callers when using
I guess this question isn't only specific to YUI, but that's the JS library

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.