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.

2 Answers 2


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, 2014 at 21:41
  • Lovely! Looks like I just need a quick plugin to do this from Twig.
    – Tim Kelty
    Jul 1, 2014 at 14:42
  • Any pointers on how I could get the two other transform parameters to work? mode and position
    – peirix
    May 8, 2015 at 12:21
  • @peirix Not sure I’m following - probably worth posting as a new question. May 9, 2015 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, 2015 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.