Comments

jhedstrom’s picture

Status: Active » Needs review

Changing the status.

jwhat’s picture

StatusFileSize
new2.04 KB

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.

robby.smith’s picture

Status: Needs review » Reviewed & tested by the community

very cool work! drush is very very helpful =)

jwhat’s picture

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.

sime’s picture

You don't know you want it until you need it.

asciikewl’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new2.02 KB

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.

cyberwolf’s picture

Subscribing.

phayes’s picture

Title: Drush command to flush presets » Drush command to flush presets and build cache
StatusFileSize
new4.9 KB

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

moshe weitzman’s picture

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.

mikeytown2’s picture

Version: 6.x-2.0-beta10 » 6.x-2.x-dev
StatusFileSize
new4.21 KB

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/sites
for 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

mikeytown2’s picture

StatusFileSize
new4.91 KB

This give percent done updates & it's a little more verbose.

chadwick wood’s picture

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?

mikeytown2’s picture

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

boran’s picture

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?

mikeytown2’s picture

no need to patch drush; one must patch imagecache

Look at imageinfo cache to auto build imagecache presets on file upload.

drewish’s picture

StatusFileSize
new5.3 KB

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.

drewish’s picture

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.

mikeytown2’s picture

the path hack is a workaround for this issue #360193: ImageAPI Broken - base_path() problem

drewish’s picture

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?

mikeytown2’s picture

#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

drewish’s picture

StatusFileSize
new5.15 KB

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 status
 Drupal 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.

drewish’s picture

I'm actually asking Drush what the site root is with drush_get_context('DRUSH_DRUPAL_ROOT');

drewish’s picture

Status: Needs review » Fixed

I went ahead and committed this to 6.x-2.x.

ao2’s picture

Hi, I've just tested drush imagecache-build and 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:

$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

drewish’s picture

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.

dshumaker’s picture

subscribing.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

ao2’s picture

Status: Closed (fixed) » Needs work

reopening. Am I the only one who got the message like in #24?

ziomizar’s picture

StatusFileSize
new5.21 KB

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.

ziomizar’s picture

Version: 6.x-2.x-dev » 6.x-2.0-beta12
Category: feature » bug
Priority: Normal » Major
StatusFileSize
new1.13 KB

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

ziomizar’s picture

Status: Needs work » Needs review
ao2’s picture

Issue tags: ++patch
StatusFileSize
new1.45 KB

@drewish: the attached patch fixes the problem in #24, it can be applied using git am so 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

nicholas.alipaz’s picture

Wow, this seems to be just languishing here... Any movement on getting the drush integration?

mikeytown2’s picture

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

fizk’s picture

Category: bug » feature
Priority: Major » Normal
Issue tags: -+patch +ImageCache 3

Marking as ImageCache 3.x Todo.