Posted by jhedstrom on September 24, 2009 at 7:21pm
17 followers
| Project: | ImageCache |
| Version: | 6.x-2.0-beta12 |
| Component: | Code |
| Category: | bug report |
| Priority: | major |
| Assigned: | Unassigned |
| Status: | needs review |
| Issue tags: | +patch |
Issue Summary
The attached patch provides an imagecache.drush.inc file that includes a command to flush presets using drush.
| Attachment | Size |
|---|---|
| imagecache.drush_.patch | 1.78 KB |
Comments
#1
Changing the status.
#2
Almost a year later, but I just found this and it was very useful. I modified the file to work with the latest version of Drush: added an alias, replaced realpath with DRUPAL_ROOT (global setting from Drush), replaced space with hyphen in the command name, replaced the messages with drupal_log() in case this is used in a more automated fashion it will save to the log, and added a message if the preset exists yet was already empty.
File attached.
#3
very cool work! drush is very very helpful =)
#4
I'm going to add the functionality that will present you with a list of your imagecache presets if none were included, because I've realized that I have about 20 and I can't possibly memorize all of their names. I will do this soon and commit an updated patch.
#5
You don't know you want it until you need it.
#6
The patches above were doing funny things, so after a bit of cleanup I implemented listing the presets if you don't give a preset and I implemented "all" for flushing all of the presets, which is often what you need after moving or cloning a site.
Modified version of imagecache.drush.inc.txt attached as I couldn't get a clean initial file for patching.
Pls mv imagecache.drush.inc.txt imagecache.drush.inc d.o doesn't like .inc attachments.
#7
Subscribing.
#8
Attached is an updated file for drush integration
I've added a second command "imagecache build", that will run through all image files in the files table and process image caches for them.
This is useful for for those that want to 'pre-process' all their files.
The one issue I ran into is that both imagemagick and GD died a horrible messy death when being called from php-cli, so I need to route the image-cache call through a
fopen('http://www.example.com')type function#9
FYI, I committed an image-flush to drush core. D7 only. I'm interested in image-build but am hoping someone can contribute that.
In the meanwhile, this looks useful for d6.
#10
I have a bash script for running drush commands. Due to imageapi using document_root it fails. BTW, I've modified the drush script to not use http requests.
Bash Script:
pushd /var/www/html/sitesfor d in `ls -Fd * | grep '/$' | grep -v '^all'`
do
echo $d
~/drush/drush -y -l http://$d -r /var/www/html imagecache-build opengraph_ogimage profile_block /var/www/html
done
popd
What I do is take the last command and see if it's a dir. If it is then set
$_SERVER['DOCUMENT_ROOT']to it.Going to reopen this issue #549074: DOCUMENT_ROOT is empty when using cli php
#11
This give percent done updates & it's a little more verbose.
#12
I'm trying to use this patch for the added imagecache build support, but I'm getting an error because my version of imagecache (6.x-2.0-beta10) doesn't have any function named "imagecache_generate_image". Has this function been added in one of the latest development builds or something?
#13
that is correct; imagecache_generate_image is in the latest dev. Thats why in #10 I changed the version to 6.x-2.x-dev
#14
Has this feature been rolled into a drush release by now, or must one still patch drush?
Aside: I was wonder if this could somehow be used to attach images that have already been uploaded as files (e.g. by ftp), attach them to a node and build the imagecache images?
#15
no need to patch drush; one must patch imagecache
Look at imageinfo cache to auto build imagecache presets on file upload.
#16
I switched around some of the argument handling to simplify it and use "drush cc" style prompting. Also changed the command names in the examples to match the current values.
#17
Why are we taking the site root as an option for the imagecache-build? That to make imagemagick happy? We should document that bit of weirdness better.
#18
the path hack is a workaround for this issue #360193: ImageAPI Broken - base_path() problem
#19
Okay so I committed the patch for #360193: ImageAPI Broken - base_path() problem so we should test if we still need the URL for that... actually doesn't drush have that information? Should we really need to replicate it?
#20
#1112428: Memory Leak is something to be aware of, if your going to (ab)use this code path. What do you mean by the URL? Not sure if this (the URL) is what your talking about but #549074-3: DOCUMENT_ROOT is empty when using cli php might help to answer your question???
In #10 I don't use a URL
#21
I ment that we shouldn't ever have to ask the users what the site root is. Drush already knows:
amorton@NY50364:~/Sites/d6/sites/all/modules/imagecache% drush statusDrupal version : 6.20
Site URI : http://default
Database driver : mysql
Database hostname : localhost
Database username : root
Database name : d6
Database : Connected
Drupal bootstrap : Successful
Drupal user : Anonymous
Default theme : garland
Administration theme : garland
PHP configuration : /private/etc/php.ini
Drush version : 4.5-dev
Drush configuration : /Users/amorton/dotfiles/.drushrc.php
Drush alias files :
Drupal root : /Users/amorton/Sites/d6
Site path : sites/default
File directory path : sites/default/files
But the getcwd() seems to do the right thing in this case:
amorton@NY50364:~/Sites/d6/sites/all/modules/imagecache% drush ev "var_dump(getcwd());"string(23) "/Users/amorton/Sites/d6"
So I think we can just drop that code.
#22
I'm actually asking Drush what the site root is with
<?phpdrush_get_context('DRUSH_DRUPAL_ROOT');
?>
#23
I went ahead and committed this to 6.x-2.x.
#24
Hi, I've just tested
drush imagecache-buildand I get this message:WD php: Division by zero in /home/ao2/public_html/drupal/sites/all/modules/imagecache/imagecache.drush.inc on line 163.several times, this happens because I have few images (19), this instruction gives 0:
<?php$mod = round($count / 200);
?>
and then the subsequent modulo operation is not defined.
I also didn't understand what the 200 is used for.
Thanks,
Antonio
#25
I believe it was to break the it up into chunks so the status messages could be output periodically. There might be a better way to achieve this.
#26
subscribing.
#27
Automatically closed -- issue fixed for 2 weeks with no activity.
#28
reopening. Am I the only one who got the message like in #24?
#29
Hi , i have noticed an other issue on the number of items returned.
If i do this query:
"SELECT filepath FROM {files} where filemime LIKE 'image%' ORDER BY fid DESC"
phpmyadmin returns 1104 images, but when i run this script from drush i get only 190 images.
i have changed the script as follow :
// Get a list of files to processes.
$file_query = db_query("SELECT filepath FROM {files} where filemime LIKE 'image%' ORDER BY fid DESC");
$files = array();
drush_log(dt('Generating file list...', array()), 'ok');
while ($filepath = db_fetch_object($file_query)) {
if (file_exists($filepath->filepath)) {
$files[] = $filepath->filepath;
}
}
Now i get correctly all images. I'm sorry but i can't do a real patch, this is my entire file.
#30
I have done the patch based on 6.x-2.0-beta12 related to the last post.
the patch fix :
- number of images returned
- current drush dir
#31
#32
@drewish: the attached patch fixes the problem in #24, it can be applied using
git amso to preserve my authorship in the commit history.I didn't experience the issue @ziomizar had, so I cannot comment on his changes, I just know that they did not fixed my own issue.
Thanks,
Antonio
#33
Wow, this seems to be just languishing here... Any movement on getting the drush integration?
#34
find me at drupal con during any one of my code sprint times; we can test and get the latest patch in. http://denver2012.drupal.org/sprints