3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Image{ public $filepath; public $width; public $height; public $mime; public $landscape; public $imageFunct; public $compression; // Image resource identifier private $image; // Is it a temporary image private $isTemp; /** * constructor * @param type $fp * @param type $isTemp - if true, will delete the image file on the destroy call * @throws Exception */ public function __construct($fp, $isTemp = false){ // Make sure file exists if(!file_exists($fp)) throw new Exception("Image source file does not exist: $fp"); $this->isTemp = $isTemp; $this->filepath = $fp; $data = getimagesize($fp); $this->width = $data[0]; $this->height = $data[1]; $this->landscape = $this->width > $this->height; $this->mime = $data['mime']; switch($this->mime){ case("image/png"): $this->image = imagecreatefrompng($this->filepath); imagealphablending($this->image, false); imagesavealpha($this->image, true); $this->imageFunct = 'imagepng'; $this->compression = 9; break; case('image/jpeg'): case('image/pjpeg'): case('image/x-jps'): $this->image = imagecreatefromjpeg($this->filepath); $this->imageFunct = 'imagejpeg'; $this->compression = 100; break; case('image/gif'): $this->image = imagecreatefromgif($this->filepath); imagealphablending($this->image, false); imagesavealpha($this->image, true); $this->imageFunct = 'imagegif'; break; default: throw new Exception("Invalid image type. Only excepts PNG, JPG, and GIF. You entered a {$this->mime} type image."); } } /** * scales the image to cover the dimensions provided * @param type $width (of canvas) * @param type $height (of canvas) */ public function scale($width, $height, $cover='fill'){ // Get new dimensions $imgRatio = $this->height/$this->width; $canvasRatio = $height/$width; if( ($canvasRatio > $imgRatio && $cover=='fill') || ($canvasRatio <= $imgRatio && $cover!='fill') ){ $finalHeight = $height; $scale = $finalHeight / $this->height; $finalWidth = $this->width * $scale; }else{ $finalWidth = $width; $scale = $finalWidth / $this->width; $finalHeight = $this->height * $scale; } // Resize the image $thumb = imagecreatetruecolor($finalWidth, $finalHeight); imagealphablending($thumb, false); imagesavealpha($thumb, true); imagecopyresampled($thumb, $this->image, 0, 0, 0, 0, $finalWidth, $finalHeight, $this->width, $this->height); $this->resize($finalWidth, $finalHeight); $this->width = $finalWidth; $this->height = $finalHeight; } /** * scales the image to cover the dimensions provided * @param type $width (of canvas) * @param type $height (of canvas) */ public function resize($width, $height){ // Resize the image $thumb = imagecreatetruecolor($width, $height); imagealphablending($thumb, false); imagesavealpha($thumb, true); imagecopyresampled($thumb, $this->image, 0, 0, 0, 0, $width, $height, $this->width, $this->height); $this->image = $thumb; $this->width = $width; $this->height = $height; } /** * tile the image to the provided dimensions * @param type $width * @param type $height * @param type $output_mimetype */ public function tile($width, $height){ // Our output image to be created $out = imagecreatetruecolor($width, $this->height); imagealphablending($out, false); imagesavealpha($out, true); // Tile that shit horiz $curr_x = 0; while($curr_x < $width){ imagecopy($out, $this->image, $curr_x, 0, 0, 0, $this->width, $this->height); $curr_x += $this->width; } // our final output image to be created $thumb = imagecreatetruecolor($width, $height); imagealphablending($thumb, false); imagesavealpha($thumb, true); // Tile that shit vert $curr_y = 0; while($curr_y < $height){ imagecopy($thumb, $out, 0, $curr_y, 0, 0, $width, $this->height); $curr_y += $this->height; } imagedestroy($out); $this->image = $thumb; } /** * Reverse all colors of the image */ public function reverseColors(){ return imagefilter($this->image, IMG_FILTER_NEGATE); } /** * Convert image to greyscale */ public function greyScale(){ return imagefilter($this->image, IMG_FILTER_GRAYSCALE); } /** * Adjust brightness level. (between 255 and -255) * @param type $brightness */ public function adjustBrightness($brightness){ if($brightness > 255) $brightness = 255; if($brightness < -255) $brightness = -255; return imagefilter($this->image, IMG_FILTER_BRIGHTNESS, $brightness); } /** * Adjust the contrast level * @param int $contrast */ public function adjustContrast($contrast){ return imagefilter($this->image, IMG_FILTER_CONTRAST, $contrast); } /** * Turns on edgeDetect Filter */ public function edgeDetect(){ return imagefilter($this->image, IMG_FILTER_EDGEDETECT); } /** * Turns on emboss Filter */ public function emboss(){ return imagefilter($this->image, IMG_FILTER_EMBOSS); } /** * Turns on gaussianBlur Filter */ public function gaussianBlur(){ return imagefilter($this->image, IMG_FILTER_GAUSSIAN_BLUR); } /** * Turns on selectiveBlur Filter */ public function selectiveBlur(){ return imagefilter($this->image, IMG_FILTER_SELECTIVE_BLUR); } /** * Turns on sketch Filter */ public function sketch(){ return imagefilter($this->image, IMG_FILTER_MEAN_REMOVAL); } /** * Adds a vignette */ function vignette(){ for($x = 0; $x < imagesx($this->image); ++$x){ for($y = 0; $y < imagesy($this->image); ++$y){ $index = imagecolorat($this->image, $x, $y); $rgb = imagecolorsforindex($this->image, $index); $sharp = 0.4; // 0 - 10 small is sharpnes, $level = 0.7; // 0 - 1 small is brighter $l = sin(M_PI / $this->width * $x) * sin(M_PI / $this->height * $y); $l = pow($l, $sharp); $l = 1 - $level * (1 - $l); $rgb['red'] *= $l; $rgb['green'] *= $l; $rgb['blue'] *= $l; $color = imagecolorallocate($this->image, $rgb['red'], $rgb['green'], $rgb['blue']); imagesetpixel($this->image, $x, $y, $color); } } return true; } /** * Pixelate the image * @param type $blocksize * @param type $advanced */ public function pixelate($blocksize, $advanced=true){ return imagefilter($this->image, IMG_FILTER_PIXELATE, $blocksize, $advanced); } /** * Adjust smoothness level * @param type $level */ public function adjustSmoothness($level){ return imagefilter($this->image, IMG_FILTER_SMOOTH, $level); } /** * Colorize an image * @param type $hexColor */ public function colorize($hexColor, $alpha){ list($r, $g, $b) = self::convertHexColor($hexColor); if($alpha < 0) $alpha = 0; if($alpha > 127) $alpha = 127; return imagefilter($this->image, IMG_FILTER_COLORIZE, $r, $g, $b, $alpha); } /** * Outputs the image directly to the browser * @param type $output_mimetype ("png", "jpg", or "gif") * (defaults to the original image's mimtype) */ public function output($output_mimetype = null){ // Get output details list($mimetype, $funct, $compression) = $this->getOutputDetails($output_mimetype); // Output and clear memory header('Content-Type: '.$mimetype); // Get and call the image creation funtion $funct($this->image, null, $compression); } /** * Destroys the generated image to free up resources, * Delete the file if it's a temporary file. * should be the last method called as the object is unusable after this. */ public function destroy(){ imagedestroy($this->image); if($this->isTemp) unlink($this->filepath); } /** * Crops the image to the given dimensions, at the given starting point * defaults to the top left * @param type $width * @param type $height * @param type $x * @param type $y */ public function crop($new_width, $new_height, $x = 0, $y = 0){ // Get dimensions $width = imagesx($this->image); $height = imagesy($this->image); // Make the dummy image that will become the new image $newImg = imagecreatetruecolor($new_width, $new_height); // Fill with transparent background imagealphablending($newImg, false); imagesavealpha($newImg, true); $transparent = imagecolorallocatealpha($newImg, 255, 255, 255, 127); imagefilledrectangle($newImg, 0, 0, $new_width, $new_height, $transparent); // Copy the pixels to the new image imagecopy($newImg, $this->image, 0, 0, 0, 0, $width, $height); $this->image = $newImg; $this->width = $width; $this->height = $height; } /** * Create an image from a base64 string * @param type $string * @return \Image */ public static function createFromBase64($string){ // decode base64 string $imgData = base64_decode(preg_replace('#^data:image/\w+;base64,#i', '', $string)); // create the image resource $formImage = imagecreatefromstring($imgData); // Fill with transparent background imagealphablending($formImage, false); imagesavealpha($formImage, true); $transparent = imagecolorallocatealpha($formImage, 255, 255, 255, 127); imagefill($formImage, 0, 0, $transparent); // Save the image to a temp png file to use in our constructor $tmpname = tempnam('/tmp', 'IMG'); // Generate and save image imagepng($formImage, $tmpname, 9); // Return an instance of the class $img = new Image($tmpname, true); return $img; } /** * Make an image of text * @param type $text * @param type $size * @param type $color * @param type $font */ public static function createTextImage($text, $font_size, $color, $font_file, $wrap_width = false){ // Make sure font file exists //if(!file_exists($font_file)) throw new Exception("Font file does not exist: {$font_file}"); // Generate wrapping text if(is_numeric($wrap_width) && $wrap_width != 0) $text = self::wrapText($font_size, $font_file, $text, $wrap_width); // Retrieve bounding box: $type_space = imagettfbbox($font_size, 0, $font_file, $text); // Determine image width and height, 10 pixels are added for 5 pixels padding: $image_width = abs($type_space[4] - $type_space[0]) + 10; $image_height = abs($type_space[5] - $type_space[1]) + 10; $line_height = self::getLineHeight($font_size, $font_file) +10; // Create image: $image = imagecreatetruecolor($image_width, $image_height); // Allocate text and background colors (RGB format): $text_color = self::getColor($image, $color); // Fill with transparent background imagealphablending($image, false); imagesavealpha($image, true); $transparent = imagecolorallocatealpha($image, 255, 255, 255, 127); imagefill($image, 0, 0, $transparent); // Fix starting x and y coordinates for the text: $x = 5; // Padding of 5 pixels. $y = $line_height - 5; // So that the text is vertically centered. // Add TrueType text to image: imagettftext($image, $font_size, 0, $x, $y, $text_color, $font_file, $text); // Save the image to a temp png file to use in our constructor $tmpname = tempnam('/tmp', 'IMG'); // Generate and save image imagepng($image, $tmpname, 9); // Return an instance of the class $img = new Image($tmpname, true); $img->crop($image_width, $image_height); return $img; } /** * Get output information * @param type $output_mimetype * @return array($mimetype, $output_funct, $compression) */ private function getOutputDetails($output_mimetype){ switch(strtoupper($output_mimetype)){ case('JPG'): case('JPEG'): $mimetype = 'image/jpeg'; $funct = 'imagejpeg'; $compression = 100; break; case('PNG'): $mimetype = 'image/png'; $funct = 'imagepng'; $compression = 9; break; case('GIF'): $mimetype = 'image/gif'; $funct = 'imagegif'; $compression = null; break; default: $mimetype = $this->mime; $funct = $this->imageFunct; $compression = $this->compression; } return array($mimetype, $funct, $compression); } private static function convertHexColor($hex){ // Remove the # if therre is one $hex = str_replace("#", "", $hex); // Convert the hex to rgb if(strlen($hex) == 3){ $r = hexdec(substr($hex, 0, 1) . substr($hex, 0, 1)); $g = hexdec(substr($hex, 1, 1) . substr($hex, 1, 1)); $b = hexdec(substr($hex, 2, 1) . substr($hex, 2, 1)); }else{ $r = hexdec(substr($hex, 0, 2)); $g = hexdec(substr($hex, 2, 2)); $b = hexdec(substr($hex, 4, 2)); } return array($r, $g, $b); } /** * Convert Hex Colors To RGB * @param type $image - image identifier * @param type $hex - the hex color code * @param type $alpha - 0 for solid - 127 for transparent * @return type color identifier * @throws Exception */ private static function getColor($image, $hex, $alpha=0){ list($r, $g, $b) = self::convertHexColor($hex); // The alpha layer seems to make things gritty, // so let's avoid it if there's no transparency $return = ($alpha==0) ? imagecolorallocatealpha($image, $r, $g, $b, $alpha) : imagecolorallocate($image, $r, $g, $b) ; // Make sure it worked if($return === false) throw new Exception("Could not create color $hex."); return $return; } /** * Inserts linebreaks to wrap text * @param type $fontSize * @param type $fontFace * @param type $string * @param type $width * @return string */ private static function wrapText($fontSize, $fontFace, $string, $width){ $ret = ""; $arr = explode(" ", $string); foreach($arr as $word){ $testboxWord = imagettfbbox($fontSize, 0, $fontFace, $word); // huge word larger than $width, we need to cut it internally until it fits the width $len = strlen($word); while($testboxWord[2] > $width && $len > 0){ $word = substr($word, 0, $len); $len--; $testboxWord = imagettfbbox($fontSize, 0, $fontFace, $word); } $teststring = $ret . ' ' . $word; $testboxString = imagettfbbox($fontSize, 0, $fontFace, $teststring); if($testboxString[2] > $width){ $ret.=($ret == "" ? "" : "\n") . $word; }else{ $ret.=($ret == "" ? "" : ' ') . $word; } } return $ret; } /** * Returns the line height based on the font and font size * @param type $fontSize * @param type $fontFace */ private static function getLineHeight($fontSize, $fontFace){ // Arbitrary text is drawn, can't be blank or just a space $type_space = imagettfbbox($fontSize, 0, $fontFace, "Robert is awesome!"); $line_height = abs($type_space[5] - $type_space[1]); return $line_height; } } $text = "This is a test"; $ttf_font_file = "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/fonts/fontawesome-webfont.ttf"; $font_size = 50; $color = "#000"; $img = Image::createTextImage($text, $font_size, $color, $ttf_font_file); $img->pixelate($blocksize); $img->output('png');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oIjua
function name:  (null)
number of ops:  18
compiled vars:  !0 = $text, !1 = $ttf_font_file, !2 = $font_size, !3 = $color, !4 = $img, !5 = $blocksize
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  536     0  E >   ASSIGN                                                   !0, 'This+is+a+test'
  537     1        ASSIGN                                                   !1, 'https%3A%2F%2Fcdnjs.cloudflare.com%2Fajax%2Flibs%2Ffont-awesome%2F4.5.0%2Ffonts%2Ffontawesome-webfont.ttf'
  538     2        ASSIGN                                                   !2, 50
  539     3        ASSIGN                                                   !3, '%23000'
  541     4        INIT_STATIC_METHOD_CALL                                  'Image', 'createTextImage'
          5        SEND_VAR                                                 !0
          6        SEND_VAR                                                 !2
          7        SEND_VAR                                                 !3
          8        SEND_VAR                                                 !1
          9        DO_FCALL                                      0  $10     
         10        ASSIGN                                                   !4, $10
  542    11        INIT_METHOD_CALL                                         !4, 'pixelate'
         12        SEND_VAR_EX                                              !5
         13        DO_FCALL                                      0          
  543    14        INIT_METHOD_CALL                                         !4, 'output'
         15        SEND_VAL_EX                                              'png'
         16        DO_FCALL                                      0          
         17      > RETURN                                                   1

Class Image:
Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 13
Branch analysis from position: 7
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 13
7 jumps found. (Code = 188) Position 1 = 48, Position 2 = 72, Position 3 = 72, Position 4 = 72, Position 5 = 84, Position 6 = 106, Position 7 = 37
Branch analysis from position: 48
1 jumps found. (Code = 42) Position 1 = 114
Branch analysis from position: 114
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 72
1 jumps found. (Code = 42) Position 1 = 114
Branch analysis from position: 114
Branch analysis from position: 72
Branch analysis from position: 72
Branch analysis from position: 84
1 jumps found. (Code = 42) Position 1 = 114
Branch analysis from position: 114
Branch analysis from position: 106
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 37
2 jumps found. (Code = 44) Position 1 = 39, Position 2 = 48
Branch analysis from position: 39
2 jumps found. (Code = 44) Position 1 = 41, Position 2 = 72
Branch analysis from position: 41
2 jumps found. (Code = 44) Position 1 = 43, Position 2 = 72
Branch analysis from position: 43
2 jumps found. (Code = 44) Position 1 = 45, Position 2 = 72
Branch analysis from position: 45
2 jumps found. (Code = 44) Position 1 = 47, Position 2 = 84
Branch analysis from position: 47
1 jumps found. (Code = 42) Position 1 = 106
Branch analysis from position: 106
Branch analysis from position: 84
Branch analysis from position: 72
Branch analysis from position: 72
Branch analysis from position: 72
Branch analysis from position: 48
filename:       /in/oIjua
function name:  __construct
number of ops:  116
compiled vars:  !0 = $fp, !1 = $isTemp, !2 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <false>
   27     2        INIT_FCALL                                               'file_exists'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $3      
          5        BOOL_NOT                                         ~4      $3
          6      > JMPZ                                                     ~4, ->13
          7    >   NEW                                              $5      'Exception'
          8        NOP                                                      
          9        FAST_CONCAT                                      ~6      'Image+source+file+does+not+exist%3A+', !0
         10        SEND_VAL_EX                                              ~6
         11        DO_FCALL                                      0          
         12      > THROW                                         0          $5
   29    13    >   ASSIGN_OBJ                                               'isTemp'
         14        OP_DATA                                                  !1
   30    15        ASSIGN_OBJ                                               'filepath'
         16        OP_DATA                                                  !0
   31    17        INIT_FCALL                                               'getimagesize'
         18        SEND_VAR                                                 !0
         19        DO_ICALL                                         $10     
         20        ASSIGN                                                   !2, $10
   32    21        FETCH_DIM_R                                      ~13     !2, 0
         22        ASSIGN_OBJ                                               'width'
         23        OP_DATA                                                  ~13
   33    24        FETCH_DIM_R                                      ~15     !2, 1
         25        ASSIGN_OBJ                                               'height'
         26        OP_DATA                                                  ~15
   34    27        FETCH_OBJ_R                                      ~17     'width'
         28        FETCH_OBJ_R                                      ~18     'height'
         29        IS_SMALLER                                       ~19     ~18, ~17
         30        ASSIGN_OBJ                                               'landscape'
         31        OP_DATA                                                  ~19
   35    32        FETCH_DIM_R                                      ~21     !2, 'mime'
         33        ASSIGN_OBJ                                               'mime'
         34        OP_DATA                                                  ~21
   36    35        FETCH_OBJ_R                                      ~22     'mime'
         36      > SWITCH_STRING                                            ~22, [ 'image%2Fpng':->48, 'image%2Fjpeg':->72, 'image%2Fpjpeg':->72, 'image%2Fx-jps':->72, 'image%2Fgif':->84, ], ->106
   37    37    >   CASE                                                     ~22, 'image%2Fpng'
         38      > JMPNZ                                                    ~23, ->48
   44    39    >   CASE                                                     ~22, 'image%2Fjpeg'
         40      > JMPNZ                                                    ~23, ->72
   45    41    >   CASE                                                     ~22, 'image%2Fpjpeg'
         42      > JMPNZ                                                    ~23, ->72
   46    43    >   CASE                                                     ~22, 'image%2Fx-jps'
         44      > JMPNZ                                                    ~23, ->72
   51    45    >   CASE                                                     ~22, 'image%2Fgif'
         46      > JMPNZ                                                    ~23, ->84
         47    > > JMP                                                      ->106
   38    48    >   INIT_FCALL_BY_NAME                                       'imagecreatefrompng'
         49        CHECK_FUNC_ARG                                           
         50        FETCH_OBJ_FUNC_ARG                               $25     'filepath'
         51        SEND_FUNC_ARG                                            $25
         52        DO_FCALL                                      0  $26     
         53        ASSIGN_OBJ                                               'image'
         54        OP_DATA                                                  $26
   39    55        INIT_FCALL_BY_NAME                                       'imagealphablending'
         56        CHECK_FUNC_ARG                                           
         57        FETCH_OBJ_FUNC_ARG                               $27     'image'
         58        SEND_FUNC_ARG                                            $27
         59        SEND_VAL_EX                                              <false>
         60        DO_FCALL                                      0          
   40    61        INIT_FCALL_BY_NAME                                       'imagesavealpha'
         62        CHECK_FUNC_ARG                                           
         63        FETCH_OBJ_FUNC_ARG                               $29     'image'
         64        SEND_FUNC_ARG                                            $29
         65        SEND_VAL_EX                                              <true>
         66        DO_FCALL                                      0          
   41    67        ASSIGN_OBJ                                               'imageFunct'
         68        OP_DATA                                                  'imagepng'
   42    69        ASSIGN_OBJ                                               'compression'
         70        OP_DATA                                                  9
   43    71      > JMP                                                      ->114
   47    72    >   INIT_FCALL_BY_NAME                                       'imagecreatefromjpeg'
         73        CHECK_FUNC_ARG                                           
         74        FETCH_OBJ_FUNC_ARG                               $34     'filepath'
         75        SEND_FUNC_ARG                                            $34
         76        DO_FCALL                                      0  $35     
         77        ASSIGN_OBJ                                               'image'
         78        OP_DATA                                                  $35
   48    79        ASSIGN_OBJ                                               'imageFunct'
         80        OP_DATA                                                  'imagejpeg'
   49    81        ASSIGN_OBJ                                               'compression'
         82        OP_DATA                                                  100
   50    83      > JMP                                                      ->114
   52    84    >   INIT_FCALL_BY_NAME                                       'imagecreatefromgif'
         85        CHECK_FUNC_ARG                                           
         86        FETCH_OBJ_FUNC_ARG                               $39     'filepath'
         87        SEND_FUNC_ARG                                            $39
         88        DO_FCALL                                      0  $40     
         89        ASSIGN_OBJ                                               'image'
         90        OP_DATA                                                  $40
   53    91        INIT_FCALL_BY_NAME                                       'imagealphablending'
         92        CHECK_FUNC_ARG                                           
         93        FETCH_OBJ_FUNC_ARG                               $41     'image'
         94        SEND_FUNC_ARG                                            $41
         95        SEND_VAL_EX                                              <false>
         96        DO_FCALL                                      0          
   54    97        INIT_FCALL_BY_NAME                                       'imagesavealpha'
         98        CHECK_FUNC_ARG                                           
         99        FETCH_OBJ_FUNC_ARG                               $43     'image'
        100        SEND_FUNC_ARG                                            $43
        101        SEND_VAL_EX                                              <true>
        102        DO_FCALL                                      0          
   55   103        ASSIGN_OBJ                                               'imageFunct'
        104        OP_DATA                                                  'imagegif'
   56   105      > JMP                                                      ->114
   58   106    >   NEW                                              $46     'Exception'
        107        ROPE_INIT                                     3  ~49     'Invalid+image+type.+Only+excepts+PNG%2C+JPG%2C+and+GIF.+You+entered+a+'
        108        FETCH_OBJ_R                                      ~47     'mime'
        109        ROPE_ADD                                      1  ~49     ~49, ~47
        110        ROPE_END                                      2  ~48     ~49, '+type+image.'
        111        SEND_VAL_EX                                              ~48
        112        DO_FCALL                                      0          
        113      > THROW                                         0          $46
        114    >   FREE                                                     ~22
   60   115      > RETURN                                                   null

End of function __construct

Function scale:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 11, Position 2 = 13
Branch analysis from position: 11
2 jumps found. (Code = 47) Position 1 = 14, Position 2 = 19
Branch analysis from position: 14
2 jumps found. (Code = 46) Position 1 = 16, Position 2 = 18
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 28
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 35
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
Branch analysis from position: 19
Branch analysis from position: 13
filename:       /in/oIjua
function name:  scale
number of ops:  75
compiled vars:  !0 = $width, !1 = $height, !2 = $cover, !3 = $imgRatio, !4 = $canvasRatio, !5 = $finalHeight, !6 = $scale, !7 = $finalWidth, !8 = $thumb
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   67     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      'fill'
   70     3        FETCH_OBJ_R                                      ~9      'height'
          4        FETCH_OBJ_R                                      ~10     'width'
          5        DIV                                              ~11     ~9, ~10
          6        ASSIGN                                                   !3, ~11
   71     7        DIV                                              ~13     !1, !0
          8        ASSIGN                                                   !4, ~13
   73     9        IS_SMALLER                                       ~15     !3, !4
         10      > JMPZ_EX                                          ~15     ~15, ->13
         11    >   IS_EQUAL                                         ~16     !2, 'fill'
         12        BOOL                                             ~15     ~16
         13    > > JMPNZ_EX                                         ~15     ~15, ->19
   74    14    >   IS_SMALLER_OR_EQUAL                              ~17     !4, !3
         15      > JMPZ_EX                                          ~17     ~17, ->18
         16    >   IS_NOT_EQUAL                                     ~18     !2, 'fill'
         17        BOOL                                             ~17     ~18
         18    >   BOOL                                             ~15     ~17
         19    > > JMPZ                                                     ~15, ->28
   76    20    >   ASSIGN                                                   !5, !1
   77    21        FETCH_OBJ_R                                      ~20     'height'
         22        DIV                                              ~21     !5, ~20
         23        ASSIGN                                                   !6, ~21
   78    24        FETCH_OBJ_R                                      ~23     'width'
         25        MUL                                              ~24     !6, ~23
         26        ASSIGN                                                   !7, ~24
         27      > JMP                                                      ->35
   80    28    >   ASSIGN                                                   !7, !0
   81    29        FETCH_OBJ_R                                      ~27     'width'
         30        DIV                                              ~28     !7, ~27
         31        ASSIGN                                                   !6, ~28
   82    32        FETCH_OBJ_R                                      ~30     'height'
         33        MUL                                              ~31     !6, ~30
         34        ASSIGN                                                   !5, ~31
   86    35    >   INIT_FCALL_BY_NAME                                       'imagecreatetruecolor'
         36        SEND_VAR_EX                                              !7
         37        SEND_VAR_EX                                              !5
         38        DO_FCALL                                      0  $33     
         39        ASSIGN                                                   !8, $33
   87    40        INIT_FCALL_BY_NAME                                       'imagealphablending'
         41        SEND_VAR_EX                                              !8
         42        SEND_VAL_EX                                              <false>
         43        DO_FCALL                                      0          
   88    44        INIT_FCALL_BY_NAME                                       'imagesavealpha'
         45        SEND_VAR_EX                                              !8
         46        SEND_VAL_EX                                              <true>
         47        DO_FCALL                                      0          
   89    48        INIT_FCALL_BY_NAME                                       'imagecopyresampled'
         49        SEND_VAR_EX                                              !8
         50        CHECK_FUNC_ARG                                           
         51        FETCH_OBJ_FUNC_ARG                               $37     'image'
         52        SEND_FUNC_ARG                                            $37
         53        SEND_VAL_EX                                              0
         54        SEND_VAL_EX                                              0
         55        SEND_VAL_EX                                              0
         56        SEND_VAL_EX                                              0
         57        SEND_VAR_EX                                              !7
         58        SEND_VAR_EX                                              !5
         59        CHECK_FUNC_ARG                                           
         60        FETCH_OBJ_FUNC_ARG                               $38     'width'
         61        SEND_FUNC_ARG                                            $38
         62        CHECK_FUNC_ARG                                           
         63        FETCH_OBJ_FUNC_ARG                               $39     'height'
         64        SEND_FUNC_ARG                                            $39
         65        DO_FCALL                                      0          
   91    66        INIT_METHOD_CALL                                         'resize'
         67        SEND_VAR_EX                                              !7
         68        SEND_VAR_EX                                              !5
         69        DO_FCALL                                      0          
   92    70        ASSIGN_OBJ                                               'width'
         71        OP_DATA                                                  !7
   93    72        ASSIGN_OBJ                                               'height'
         73        OP_DATA                                                  !5
   94    74      > RETURN                                                   null

End of function scale

Function resize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oIjua
function name:  resize
number of ops:  40
compiled vars:  !0 = $width, !1 = $height, !2 = $thumb
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  101     0  E >   RECV                                             !0      
          1        RECV                                             !1      
  104     2        INIT_FCALL_BY_NAME                                       'imagecreatetruecolor'
          3        SEND_VAR_EX                                              !0
          4        SEND_VAR_EX                                              !1
          5        DO_FCALL                                      0  $3      
          6        ASSIGN                                                   !2, $3
  105     7        INIT_FCALL_BY_NAME                                       'imagealphablending'
          8        SEND_VAR_EX                                              !2
          9        SEND_VAL_EX                                              <false>
         10        DO_FCALL                                      0          
  106    11        INIT_FCALL_BY_NAME                                       'imagesavealpha'
         12        SEND_VAR_EX                                              !2
         13        SEND_VAL_EX                                              <true>
         14        DO_FCALL                                      0          
  107    15        INIT_FCALL_BY_NAME                                       'imagecopyresampled'
         16        SEND_VAR_EX                                              !2
         17        CHECK_FUNC_ARG                                           
         18        FETCH_OBJ_FUNC_ARG                               $7      'image'
         19        SEND_FUNC_ARG                                            $7
         20        SEND_VAL_EX                                              0
         21        SEND_VAL_EX                                              0
         22        SEND_VAL_EX                                              0
         23        SEND_VAL_EX                                              0
         24        SEND_VAR_EX                                              !0
         25        SEND_VAR_EX                                              !1
         26        CHECK_FUNC_ARG                                           
         27        FETCH_OBJ_FUNC_ARG                               $8      'width'
         28        SEND_FUNC_ARG                                            $8
         29        CHECK_FUNC_ARG                                           
         30        FETCH_OBJ_FUNC_ARG                               $9      'height'
         31        SEND_FUNC_ARG                                            $9
         32        DO_FCALL                                      0          
  109    33        ASSIGN_OBJ                                               'image'
         34        OP_DATA                                                  !2
  110    35        ASSIGN_OBJ                                               'width'
         36        OP_DATA                                                  !0
  111    37        ASSIGN_OBJ                                               'height'
         38        OP_DATA                                                  !1
  112    39      > RETURN                                                   null

End of function resize

Function tile:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
2 jumps found. (Code = 44) Position 1 = 39, Position 2 = 19
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 68
Branch analysis from position: 68
2 jumps found. (Code = 44) Position 1 = 70, Position 2 = 54
Branch analysis from position: 70
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 54
2 jumps found. (Code = 44) Position 1 = 70, Position 2 = 54
Branch analysis from position: 70
Branch analysis from position: 54
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 39, Position 2 = 19
Branch analysis from position: 39
Branch analysis from position: 19
filename:       /in/oIjua
function name:  tile
number of ops:  76
compiled vars:  !0 = $width, !1 = $height, !2 = $out, !3 = $curr_x, !4 = $thumb, !5 = $curr_y
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  120     0  E >   RECV                                             !0      
          1        RECV                                             !1      
  123     2        INIT_FCALL_BY_NAME                                       'imagecreatetruecolor'
          3        SEND_VAR_EX                                              !0
          4        CHECK_FUNC_ARG                                           
          5        FETCH_OBJ_FUNC_ARG                               $6      'height'
          6        SEND_FUNC_ARG                                            $6
          7        DO_FCALL                                      0  $7      
          8        ASSIGN                                                   !2, $7
  124     9        INIT_FCALL_BY_NAME                                       'imagealphablending'
         10        SEND_VAR_EX                                              !2
         11        SEND_VAL_EX                                              <false>
         12        DO_FCALL                                      0          
  125    13        INIT_FCALL_BY_NAME                                       'imagesavealpha'
         14        SEND_VAR_EX                                              !2
         15        SEND_VAL_EX                                              <true>
         16        DO_FCALL                                      0          
  128    17        ASSIGN                                                   !3, 0
  129    18      > JMP                                                      ->37
  130    19    >   INIT_FCALL_BY_NAME                                       'imagecopy'
         20        SEND_VAR_EX                                              !2
         21        CHECK_FUNC_ARG                                           
         22        FETCH_OBJ_FUNC_ARG                               $12     'image'
         23        SEND_FUNC_ARG                                            $12
         24        SEND_VAR_EX                                              !3
         25        SEND_VAL_EX                                              0
         26        SEND_VAL_EX                                              0
         27        SEND_VAL_EX                                              0
         28        CHECK_FUNC_ARG                                           
         29        FETCH_OBJ_FUNC_ARG                               $13     'width'
         30        SEND_FUNC_ARG                                            $13
         31        CHECK_FUNC_ARG                                           
         32        FETCH_OBJ_FUNC_ARG                               $14     'height'
         33        SEND_FUNC_ARG                                            $14
         34        DO_FCALL                                      0          
  131    35        FETCH_OBJ_R                                      ~16     'width'
         36        ASSIGN_OP                                     1          !3, ~16
  129    37    >   IS_SMALLER                                               !3, !0
         38      > JMPNZ                                                    ~18, ->19
  135    39    >   INIT_FCALL_BY_NAME                                       'imagecreatetruecolor'
         40        SEND_VAR_EX                                              !0
         41        SEND_VAR_EX                                              !1
         42        DO_FCALL                                      0  $19     
         43        ASSIGN                                                   !4, $19
  136    44        INIT_FCALL_BY_NAME                                       'imagealphablending'
         45        SEND_VAR_EX                                              !4
         46        SEND_VAL_EX                                              <false>
         47        DO_FCALL                                      0          
  137    48        INIT_FCALL_BY_NAME                                       'imagesavealpha'
         49        SEND_VAR_EX                                              !4
         50        SEND_VAL_EX                                              <true>
         51        DO_FCALL                                      0          
  140    52        ASSIGN                                                   !5, 0
  141    53      > JMP                                                      ->68
  142    54    >   INIT_FCALL_BY_NAME                                       'imagecopy'
         55        SEND_VAR_EX                                              !4
         56        SEND_VAR_EX                                              !2
         57        SEND_VAL_EX                                              0
         58        SEND_VAR_EX                                              !5
         59        SEND_VAL_EX                                              0
         60        SEND_VAL_EX                                              0
         61        SEND_VAR_EX                                              !0
         62        CHECK_FUNC_ARG                                           
         63        FETCH_OBJ_FUNC_ARG                               $24     'height'
         64        SEND_FUNC_ARG                                            $24
         65        DO_FCALL                                      0          
  143    66        FETCH_OBJ_R                                      ~26     'height'
         67        ASSIGN_OP                                     1          !5, ~26
  141    68    >   IS_SMALLER                                               !5, !1
         69      > JMPNZ                                                    ~28, ->54
  146    70    >   INIT_FCALL_BY_NAME                                       'imagedestroy'
         71        SEND_VAR_EX                                              !2
         72        DO_FCALL                                      0          
  148    73        ASSIGN_OBJ                                               'image'
         74        OP_DATA                                                  !4
  150    75      > RETURN                                                   null

End of function tile

Function reversecolors:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oIjua
function name:  reverseColors
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  156     0  E >   INI

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
266.47 ms | 1428 KiB | 18 Q