While upgrading to the new image.module for 4.6.0, I hacked an update script to create missing image derivatives -- i.e. image sizes -- for images already in the database. It processes images in batches to avoid time-outs, and it should be run after using update-image.php.

The script is located in my sandbox and is called update-image-derivatives.php. Let me know if you find this useful!

CommentFileSizeAuthor
#4 update-image-derivatives.patch3.45 KBpegmonkey

Comments

pegmonkey’s picture

I found that it did make the derivatives. However, all of mine ended up being the same size. It didn't scale them at all. I ended up with preview images named .preview.jpg which is correct, however they were the same size as the original image. The thumbnails got created and were the same size also. Also, the table "file" didn't have the the filename field populated for the entries. I looked at the script, but since I'm new to php, I'm not sure what's going on with it.

Thanks.

pegmonkey’s picture

$label not declared changed query from this

db_query("INSERT INTO {files} (fid, nid, filename, filepath, filemime, filesize, list) VALUES (%d, %d, '%s', '%s', '%s', '%d', %d)",
$fid, $row->nid, $label, file_create_path($filename), $row->filemime, $row->filesize, 0);

to

db_query("INSERT INTO {files} (fid, nid, filename, filepath, filemime, filesize, list) VALUES (%d, %d, '%s', '%s', '%s', '%d', %d)",
$fid, $row->nid, $size['label'], file_create_path($filename), $row->filemime, $row->filesize, 0);

I'm still trying to figure out why it won't resize...

pegmonkey’s picture

Ok, it DOES resize, create the db entries now too.. however, $row->filesize doesn't populate the db with the correct file size yet... still working on that.

pegmonkey’s picture

StatusFileSize
new3.45 KB

I got the bugs worked out that mattered to me. It now populates the "files" table with the correct filesize and filename info. I'd recommend removing all "files" table entries that don't conatain "_original", but that's just me. Make sure to read the script before using. Thanks again to njivy. It also makes a great tool if you should decide to change add or delete derivative sizes.

msameer’s picture

It's a must to empty the table otherwise you'll end up with multiple thumbs, I also was incrementing the min nid manually each run.

drewish’s picture

Status: Needs review » Fixed

hopefully everyone that's going to use this has.

Anonymous’s picture

Status: Fixed » Closed (fixed)