All pastes #97378 Raw Edit

eml

public text v1 · immutable
#97378 ·published 2006-07-23 17:49 UTC
rendered paste body
  // Convert PNG-images to JPEG
  // Pass the image url and new url to it
  public function convertToJpeg($oldUrl, $newUrl)
  {
    $source = imagecreatefrompng($oldUrl);
    $imgX = imagesx($source);
    $imgY = imagesy($source);
    $dest = imagecreatetruecolor($imgX, $imgY);
    imagecopy($dest, $source, 0, 0, $imgX, $imgY, $imgX, $imgY);
    imagejpeg($dest, $newUrl);
    imagedestroy($dest);
    imagedestroy($source);

    // Set new values
    $this->imageLocation = $newUrl;
    $temp = explode("/", $newUrl);
    $this->imageName = end($temp);
  }