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.


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->resize($transform->width, $transform->height);
  • 3
    and that pretty much sums up why i love craft!!
    – Ben Croker
    Jun 30 '14 at 21:41
  • Lovely! Looks like I just need a quick plugin to do this from Twig.
    – Tim Kelty
    Jul 1 '14 at 14:42
  • Any pointers on how I could get the two other transform parameters to work? mode and position
    – peirix
    May 8 '15 at 12:21
  • @peirix Not sure I’m following - probably worth posting as a new question. May 9 '15 at 0:20
  • @BrandonKelly I actually figured it out. What I was after was a way to send in width, height, quality, mode and position, like I would do with a regular assets transform. But I found that the $image will have both scaleAndCrop (which will take position) and scaleToFit.
    – peirix
    May 10 '15 at 20:01


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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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