Take the 2-minute tour ×
Craft CMS Stack Exchange is a question and answer site for administrators, end users, developers and designers for Craft CMS. It's 100% free, no registration required.

Curious if I'm able to use the resizer on a random, sourced image, not coming from a field anywhere.

So I would just be passing a string to the path of the image.

share|improve this question

2 Answers 2

up vote 7 down vote accepted

While transforms are an asset-only feature, you can get at all of the underlying image manipulation features pretty easily using the ImagesService.

$image = craft()->images->loadImage($imageSource);
$image->setQuality($quality);
$image->resize($transform->width, $transform->height);
$image->saveAs($targetFile);
share|improve this answer
3  
and that pretty much sums up why i love craft!! –  Ben Croker Jun 30 at 21:41
    
Lovely! Looks like I just need a quick plugin to do this from Twig. –  Tim Kelty Jul 1 at 14:42

No.

A transform can only be applied to an AssetFileModel, and there is no AssetFileModel for a random image.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.