Advertisement
Guest User

Untitled

a guest
Aug 18th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. <cfscript>
  2.  
  3. img = imageNew(
  4. source = "",
  5. width = 16,
  6. height = 2000,
  7. canvasColor = "ff3366"
  8. );
  9.  
  10. width = imageGetWidth( img );
  11. height = imageGetHeight( img );
  12. boxSize = 100;
  13.  
  14. // When scaling the image, whichever dimension has the largest magnitude becomes
  15. // our limiting factor. This is the magnitude that drives the proportional scaling.
  16. sizeConstraint = max( width, height );
  17.  
  18. // We only need to resize the image if some part of it doesn't fit inside the box.
  19. if ( sizeConstraint > boxSize ) {
  20.  
  21. // CAUTION: In earlier versions of Lucee, this will not work because the
  22. // proportional scaling of the image will cause the WIDTH to be LESS THAN 1. As
  23. // such, the underlying Java code will try to create a canvas of WIDTH = 0, which
  24. // is invalid.
  25. imageScaleToFit( img, boxSize, boxSize, "highestPerformance" );
  26.  
  27. }
  28.  
  29. imageWrite( img, "./output-scaled.png" );
  30.  
  31. </cfscript>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement