Since no one has replied at this time, I thought I'd give a crack at an answer (I really don't know if this will work).
Some goodies from a quick scan of thumb.php: $img = wfLocalFile( $fileName ); $params = array( 'width' => 100, 'height' => 100, ); $img->transform( $params, File::RENDER_NOW ); $localpath = $thumb->getPath(); $thumbPath = $img->getThumbPath( $thumbName ); That's my guess. I havn't tested it or anything. - Hunter F. On Tue, Mar 27, 2012 at 7:03 PM, Daniel Renfro <[email protected]>wrote: > MW gurus, > > I am working on an API module to an extension and would like to create > thumbnails programmatically for some images (if they don't already have > them.) > > The includes/filerepo/File.php file contains a createThumb() method, which > looks like it's what I want. From the comment block directly above the > aforementioned method: > /** > * Create a thumbnail of the image having the specified width/height. > * The thumbnail will not be created if the width is larger than the > * image's width. Let the browser do the scaling in this case. > * The thumbnail is stored on disk and is only computed if the thumbnail > * file does not exist OR if it is older than the image. > * Returns the URL. > * > * .... > */ > > However, this method always returns the url of the file itself and not the > thumb. From what I can tell it never generates the thumbnail (it's not in > the filesystem repo in any directory.) My code is: > > <?php > > # ...query to get a list of recently uploaded images (quite simple) .... > $result = $dbr->select(); > > # loop through them and get a thumbnail & url > foreach ( $result as $row ) { > $title = Title::newFromText( $row->page_title, NS_FILE ); > $file = wfFindFile( $title ); > if ( !$file ) { > continue; > } > $thumbnail_url = $file->createThumb( 80 ); # width in pixels > ...add to the API result... > } > ...return... > > ?> > > I'm sure that my query return valid page titles/namespaces, and that the > files exist (both in the wiki and in the filesystem.) They are all local, > and some are quite large. I'd hate to have to send the entire image and > make the browser do the scaling, as the thumbnail will get reused and the > resizing is only done once. > > Any ideas fellow MW gurus? What am I missing? > > -Daniel Renfro > > _______________________________________________ > Wikitech-l mailing list > [email protected] > https://lists.wikimedia.org/mailman/listinfo/wikitech-l > _______________________________________________ Wikitech-l mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/wikitech-l
