Jump to content

emma57573

Members
  • Posts

    106
  • Joined

  • Last visited

    Never

Everything posted by emma57573

  1. Thanks for your help, I simplified it a bit as I don't need to check for extensions but it worked a treat. Cleaned up 790 images great was hoping for move though have 219,000 images on site but it seems like most of them are used $row="select url from images_keep where id !=''"; mysql_query($row) or die('Query failed keepimage: ' . mysql_error()); $image[] = $row['url']; // put images to keep in array $folder = "uploadedimages/"; // set folder path to images $files = glob($folder.'*.*'); // open folder and get files foreach ($files as $img) { $ext = strtolower($img); // make it lower case for ease if (!in_array($ext, $image)){ unlink($ext); // remove image } I tested it by inserting it into a table first to inspect the images to delete, too scary to run straight off! But works great thanks
  2. Thanks for that, that makes sen e. I will have a crack at that when I get home and let you know how I get on. Thanks
  3. Hi Im trying to write a script to clean up my image directory which has quite a lot of unused images that have built up over time. In order to do this I am doing the following. First Create a database table called 'image_clean' Then I'm searching through 3 tables and collecting all the image file names and dumping the names in the table 'image_clean' Can do that no problem. So now I have all the images I need in this one table 'image_clean' I now want to go through my directory 'image_uploads' and delete anything thats not in the 'image_clean' table. I know how to delete the files using unlink Im just unsure how to search through the directory file by file and check the file against the database. Im asumming I need to put them in an array. Could anyone give be a clue or two to get me started. I have no problem checking a database against a directory but when its the other way round 'checking a directory against a database I'm lost. What I might do is pop the files to delete in a new database called 'image_delete' so that I can then check the images to delete before I write the unlink script. But I'm just not sure how to pick up each file and compare it to the table. Thanks in advance.
  4. I have a line of code that has been working for over a year, then two days ago it failed in a few areas on my site and I hadnt made any changes. I contacted the host and there was no server updates etc. Its a php/imagemagick issue, basically the "widthxheight^ - Minimum values of width and height given, aspect ratio preserved" command does not work and fails to import the image at all when I add ^ to my code. I need it though and im getting fustrated, for now ive changed my code to: exec("convert $path1 -thumbnail 200x180 -colorspace rgb -gravity center -extent 170x150 $path2"); which works ok but is not spot on like it was before, what I really want is exec("convert $path1 -thumbnail 170x150^ -colorspace rgb -gravity center -extent 170x150 $path2"); What ever I do I cant get ^ to work anymore but oddly all other imagemagick commands are fine.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.