private static function saveBookletImage($bookletCode, $imageName, $base64Image) { $bookletImagesRoot = DBPreferencesType::getPreferenceS(Constants::BOOKLET_IMAGE_PATH); $bookletImageDirectory = FileUtils::buildPath($bookletImagesRoot, $bookletCode); FileUtils::createDir($bookletImageDirectory); $imageEditor = ImageEditor::newImageBase64($base64Image); $bookletImagePath = FileUtils::buildPath($bookletImagesRoot, $bookletCode, $imageName); $imageEditor->saveImage($bookletImagePath); return FileUtils::buildPath($bookletCode, $imageName); }
<?php /** * The PHP Image Editor user interface. * @author $Author$ * @version $Id: editor.php 761 2007-02-24 02:18:05Z ray $ * @package ImageManager */ require_once 'config.inc.php'; require_once 'Classes/ImageManager.php'; require_once 'Classes/ImageEditor.php'; $manager = new ImageManager($IMConfig); $editor = new ImageEditor($manager); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title></title> <script type="text/javascript"> _backend_url = "<?php print $IMConfig['backend_url']; ?> "; </script> <link href="<?php print $IMConfig['base_url']; ?> assets/editor.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="<?php print $IMConfig['base_url'];
<?php /** * The PHP Image Editor user interface. * @author $Author: Wei Zhuo $ * @version $Id: editor.php 26 2004-03-31 02:35:21Z Wei Zhuo $ * @package ImageManager */ defined('_VALID_MOS') or die('Direct Access to this location is not allowed.'); require_once 'config.inc.php'; require_once 'Classes/ImageManager.php'; require_once 'Classes/ImageEditor.php'; $manager = new ImageManager($IMConfig); $editor = new ImageEditor($manager); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title></title> <link href="assets/editor.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="assets/slider.js"></script> <script type="text/javascript" src="assets/popup.js"></script> <script type="text/javascript"> /*<![CDATA[*/ window.resizeTo(673, 531); if(window.opener) I18N = window.opener.I18N; /*]]>*/ </script>
/** * fill an area of image with another image, scaled and drifted * * @param ImageEditor $fillImg * @param int $x * @param int $y * @param int $width * @param int $height * @param int $driftX * @param int $driftY */ public function fillinArea(ImageEditor $fillImg, $x, $y, $width, $height, $driftX = 0, $driftY = 0) { // create a mask for area $maskImg = new ImageEditor(); $maskImg->createCanvas($width, $height); // fill mask $maskImg->fillin($fillImg, $driftX, $driftY); // drop masked image into image $this->dropin($maskImg, $x, $y); }
<?php include_once '../lib/ImageEditor.php'; // create destination image $dst = new ImageEditor(); // assing canvas size $dst->createCanvas(100, 200); /** * cut all4 centered to canvas size */ $src = new ImageEditor(); $src->loadImageFile('all4.jpg'); // fill destination image with source image // keeping destination canvas-size(100,200) $dst->fillin($src); // write the image $dst->writeImageFile('out1.jpg', ImageEditor::JPG, 75); /** * apply drift to kai(right 120) */ $src = new ImageEditor(); $src->loadImageFile('all4.jpg'); $dst->fillin($src, 120, 0); // write the image $dst->writeImageFile('out2.jpg', ImageEditor::JPG, 75); /** * apply drift to Anne (left -100) */ $src = new ImageEditor(); $src->loadImageFile('all4.jpg'); $dst->fillin($src, -100, 0);
public static function resize($strFileName = "", $intWidth = 100, $intHeight = 75, $intTemplate = RESIZE_EXACT, $intQuality = 75, $blnOverwrite = FALSE, $strName = "", $blnToScreen = FALSE, $blnGrayscale = FALSE) { $strReturn = $strName; if (empty($strReturn)) { if (!$blnOverwrite) { //*** Generate a random name. $strExtension = self::getExtension(basename($strFileName)); $strReturn = dirname($strFileName) . "/{$intWidth}x{$intHeight}_" . basename($strFileName, $strExtension) . "_" . strtotime("now") . "{$strExtension}"; } else { $strReturn = $strFileName; } } $objEditor = new ImageEditor(basename($strFileName), dirname($strFileName) . "/"); switch ($intTemplate) { case RESIZE_CROP: //*** Don't blow the image up if it is smaller then the destination. if ($intWidth > $objEditor->getWidth() && $intHeight > $objEditor->getHeight()) { //*** Skip the resize. } else { $destX = ($objEditor->getWidth() - $intWidth) / 2; $destY = ($objEditor->getHeight() - $intHeight) / 2; $objEditor->crop(round($destX), round($destY), $intWidth, $intHeight); } break; case RESIZE_FIT_CROP: //*** Resize the image to fit into the boundary box. //*** Portrait source. $destWidth = $intWidth; $destHeight = $destWidth / $objEditor->getWidth() * $objEditor->getHeight(); if ($destHeight < $intHeight) { //*** Landscape source. $destHeight = $intHeight; $destWidth = $destHeight / $objEditor->getHeight() * $objEditor->getWidth(); } //*** Don't blow the image up if it is smaller then the destination. if (round($destWidth) > $objEditor->getWidth() && round($destHeight) > $objEditor->getHeight()) { //*** Skipt the resize. $destX = ($objEditor->getWidth() - $intWidth) / 2; $destY = ($objEditor->getHeight() - $intHeight) / 2; $objEditor->crop(round($destX), round($destY), $intWidth, $intHeight); } else { $objEditor->resize(round($destWidth), round($destHeight)); $destX = ($objEditor->getWidth() - $intWidth) / 2; $destY = ($objEditor->getHeight() - $intHeight) / 2; $objEditor->crop(round($destX), round($destY), $intWidth, $intHeight); } break; case RESIZE_DISTORT: //*** Don't blow the image up if it is smaller then the destination. if ($intWidth > $objEditor->getWidth() && $intHeight > $objEditor->getHeight()) { //*** Skipt the resize. } else { $objEditor->resize($intWidth, $intHeight); } break; case RESIZE_EXACT: $destWidth = $intWidth; $destHeight = $destWidth / $objEditor->getWidth() * $objEditor->getHeight(); if ($destHeight > $intHeight) { //*** Landscape source. $destHeight = $intHeight; $destWidth = $destHeight / $objEditor->getHeight() * $objEditor->getWidth(); } //*** Don't blow the image up if it is smaller then the destination. if (round($destWidth) > $objEditor->getWidth() && round($destHeight) > $objEditor->getHeight()) { //*** Skipt the resize. } else { $objEditor->resize(round($destWidth), round($destHeight)); } break; } if ($blnGrayscale) { $objEditor->grayscale(); } if (!empty($strReturn)) { if ($blnToScreen) { //*** Return image. $objEditor->outputImage($intQuality); } else { //*** Write file to disk. $objEditor->outputFile(basename($strReturn), dirname($strReturn) . "/", $intQuality); } } return $strReturn; }
function change_image($nazwa, $katalog, $w, $h, $new_nazwa = "") { if (file_exists($katalog . "/" . $nazwa)) { $plik = $katalog . "/" . $nazwa; } else { $plik = ""; } if (strlen($plik) > 0 && ($w > 0 || $h > 0)) { list($old_w, $old_h) = getimagesize($plik); $image = new ImageEditor($nazwa, $katalog); if ($w > 0 && $h == 0) { $new_w = $w; $new_h = ceil($new_w * $old_h / $old_w); $image->resize($new_w, $new_h); } else { if ($h > 0 && $w == 0) { $new_h = $h; $new_w = ceil($new_h * $old_w / $old_h); $image->resize($new_w, $new_h); } else { if ($h > 0 && $w > 0) { $image->resize($w, $h); } } } if (strlen($new_nazwa) > 0) { $image->outputFile($new_nazwa, $katalog . "/"); chmod($katalog . "/" . $new_nazwa, 0644); } else { $image->outputFile($nazwa, $katalog . "/"); chmod($katalog . "/" . $nazwa, 0644); } } }
/** * Executes RotateImage action * * This action can be used into an ajax action to rotate an image. This function requires * some parameters: * image : The name of the image to resize * imagePath : The full image path * degrees : The angle value for rotation. It can be 90, 180, 270 * imageType : The new image type. This parameter must be 1-GIF 2-JPG 3-PNG. Other * formats will be ignored * imageQuality : The new value for the image quality. Applies only to JPG images * * return A JSon header. */ public function executeRotateImage() { $imageEditor = new ImageEditor($this->getRequestParameter('image'), sfConfig::get('app_images_path')); $imageEditor->rotate($this->getRequestParameter('degrees')); $imageEditor->outputFile($this->getRequestParameter('image'), sfConfig::get('app_images_path'), $this->getRequestParameter('imageType'), $this->getRequestParameter('imageQuality')); // Produces the output header for ajax calling. $output = ''; if ($this->getRequestParameter('previewWidth') != 0 && $this->getRequestParameter('previewHeight') != 0) { $imageAttributes = w3sClassImageManager::getImageAttributes($this->getRequestParameter('image'), $this->getRequestParameter('previewWidth'), $this->getRequestParameter('previewHeight'), $this->getRequestParameter('setCanvas')); $output = '[["w3s_image_size", "' . $imageAttributes["size"] . '"],["w3s_image_width", "' . $imageAttributes["width"] . '"],["w3s_image_height", "' . $imageAttributes["height"] . '"],["w3s_image_preview", "' . $imageAttributes["image"] . '"],["w3s_image_canvas", "' . $imageAttributes["canvas"] . '"],["w3s_start_width", "' . $imageAttributes["width"] . '"],["w3s_start_height", "' . $imageAttributes["height"] . '"]]'; } $this->getResponse()->setHttpHeader("X-JSON", '(' . $output . ')'); return sfView::HEADER_ONLY; }
<? /** * The frame that contains the image to be edited. * @author $Author: Wei Zhuo $ * @version $Id: editorFrame.php 26 2004-03-31 02:35:21Z Wei Zhuo $ * @package ImageManager */ require_once('config.inc.php'); require_once('Classes/ImageManager.php'); require_once('Classes/ImageEditor.php'); $manager = new ImageManager($IMConfig); $editor = new ImageEditor($manager); $imageInfo = $editor->processImage(); ?> <html> <head> <title></title> <link href="assets/editorFrame.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="assets/wz_jsgraphics.js"></script> <script type="text/javascript" src="assets/EditorContent.js"></script> <script type="text/javascript"> if(window.top) I18N = window.top.I18N; function i18n(str) { if(I18N)
<?php /** * The frame that contains the image to be edited. * @author $Author$ * @version $Id$ * @package ImageManager */ require_once 'config.inc.php'; require_once 'Classes/ImageManager.php'; require_once 'Classes/ImageEditor.php'; $manager = new ImageManager($IMConfig); $editor = new ImageEditor($manager); $imageInfo = $editor->processImage(); ?> <html> <head> <title></title> <link href="assets/editorFrame.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="assets/wz_jsgraphics.js"></script> <script type="text/javascript" src="assets/EditorContent.js"></script> <script type="text/javascript"> //if(window.top) // I18N = window.top.I18N; function i18n(str) { // if(I18N) // return (I18N[str] || str); // else return str;
function tb_post_thumb($generate = false, $alt_text = '', $resize_width = 0, $resize_height = 0, $crop_x = 0, $crop_y = 0, $entry = null) { global $post; if ($entry) { $post = $entry; } $settings = get_option('post_thumbnail_settings'); if ($resize_width) { $settings['resize_width'] = $resize_width; } if ($resize_height) { $settings['resize_height'] = $resize_height; } // find an image from your domain if (preg_match('/<img (.*?)src="https?:\\/\\/(www\\.)?' . str_replace('/', '\\/', $settings['domain_name']) . '\\/(.*?)"/i', $post->post_content, $matches)) { // put matches into recognizable vars // fix later, assumes document root will match url structure $the_image = $settings['base_path'] . '/' . $matches[3]; // check if image exists on server // if doesn't exist, can't do anything so return default image if (!file_exists($the_image)) { return tb_post_thumb_gen_image(str_replace($settings['full_domain_name'], $settings['base_path'], $settings['default_image']), $settings['default_image'], $alt_text, $generate); } $dest_path = pathinfo($the_image); // dir to save thumbnail to $save_dir = $dest_path['dirname'] . "/{$settings['folder_name']}"; // name to save to $filename_suffix = $resize_width . 'x' . $resize_height . '-' . $crop_x . '-' . $crop_y; $filename = substr($dest_path['basename'], 0, strrpos($dest_path['basename'], ".")); if ($settings['append'] == 'true') { $rename_to = $filename . $settings['append_text'] . '-' . $filename_suffix . '.' . $dest_path['extension']; } else { $rename_to = $settings['append_text'] . $filename . '-' . $filename_suffix . '.' . $dest_path['extension']; } // check if file already exists // return location if does if (file_exists($save_dir . '/' . $rename_to)) { $imagelocation = str_replace($settings['base_path'], $settings['full_domain_name'], $save_dir . '/' . $rename_to); return tb_post_thumb_gen_image($save_dir . '/' . $rename_to, $imagelocation, $alt_text, $generate); } // sticky bit? if (!is_dir($save_dir)) { mkdir($save_dir, 0777); } // manipulate thumbnails $thumb = new ImageEditor($dest_path['basename'], $dest_path['dirname'] . '/'); $thumb->resize($settings['resize_width'], $settings['resize_height'], $settings['keep_ratio']); if ($settings['crop_exact'] == 'true' || $crop_x != 0 && $crop_y != 0) { if ($crop_x != 0 && $crop_y != 0) { $settings['resize_width'] = $crop_x; $settings['resize_height'] = $crop_y; } if ($thumb->x > $settings['resize_width'] || $thumb->y > $settings['resize_height']) { $thumb->crop((int) (($thumb->x - $settings['resize_width']) / 2), 0, $settings['resize_width'], $settings['resize_height']); } } $thumb->outputFile($save_dir . "/" . $rename_to, ""); chmod($save_dir . "/" . $rename_to, 0666); $imagelocation = str_replace($settings['base_path'], $settings['full_domain_name'], $save_dir . '/' . $rename_to); return tb_post_thumb_gen_image($save_dir . '/' . $rename_to, $imagelocation, $alt_text, $generate); } else { if (!empty($settings['video_regex']) && tb_post_thumb_check_video($settings['video_regex'])) { $settings['default_image'] = $settings['video_default']; } return tb_post_thumb_gen_image(str_replace($settings['full_domain_name'], $settings['base_path'], $settings['default_image']), $settings['default_image'], $alt_text, $generate); } }
<?php include_once '../lib/ImageEditor.php'; $src = new ImageEditor(); $dst = new ImageEditor(); $dst->createCanvas(200, 400); $src->loadImageFile('kai_schwanger.jpg'); $dst->fillin($src, 0, 1000); $drop = new ImageEditor(); $drop->loadImageFile('ruth.jpg'); #$dst->dropin($drop, 20 ,50); $dst->fillinArea($drop, 10, 20, 100, 100); $dst->fillinArea($drop, 10, 350, 100, 100); #$src->rotate(90); #$dst->fitin($src); #$dst->applyGrayscale(); #$dst->pseudosepia(20); #$dst->sepia(60); #$dst->grayscale(); $dst->writeImageFile('out.jpg', ImageEditor::JPG, 75); #$src->writeImageFile('out.jpg', ImageEditor::JPG, 75); #$dst->displayImage('JPG');
require_once "../lib/class.image_upload.php"; require_once "../lib/class.image_resize.php"; $objImageupload = new imageFileUpload(); $objImageupload->tag_name = "file_name"; $a_tempFileName = explode(".", strtolower($_FILES['file_name']['name'])); $objImageupload->file_name = $a_tempFileName[0] . "." . $a_tempFileName[1]; $newFileName = $objImageupload->file_name; $objImageupload->storing_directory = IMAGE_UPLOAD_PATH; $objImageupload->image_extensions = "jpg,gif,png,jpeg"; if (false == $objImageupload->upload()) { $error = $objImageupload->errorMsg(); echo "Error : " . $error; } $outputFileName = $objImageupload->file_name; $destinationPath = $objImageupload->storing_directory; $objImageEditor = new ImageEditor($objImageupload->file_name, $objImageupload->storing_directory); $objImageEditor->resizeInProportion($objImageEditor->getWidth(), $objImageEditor->getHeight(), 320); $objImageEditor->outputFile($outputFileName, $destinationPath); chmod($objImageupload->storing_directory . $objImageupload->file_name, 0777); /* $image_height = 320; $image_width = 400; $arfilename = $objUpload->upload($id,'file_name',IMAGE_UPLOAD_PATH,'jpeg,gif,png,JPG,JPEG,jpeg'); $filename = $arfilename[0]; //$objUpload->smart_resize_image(IMAGE_UPLOAD_PATH.$arfilename[0],$image_height,$image_width,IMAGE_UPLOAD_PATH,true,$arfilename[0],false); */ // $image->load(IMAGE_UPLOAD_PATH.$arfilename[0]); // $image->resize(320,316); // $image->save(IMAGE_UPLOAD_PATH.$arfilename[0]); // $WaterMarkText = "fototime.com"; // $image->watermarkImage (IMAGE_UPLOAD_PATH.$arfilename[0], $WaterMarkText, //IMAGE_UPLOAD_PATH.$arfilename[0]);
public static function updateImages($id, $oldCode, $imagesFromFront) { $imagesFromFront = $imagesFromFront == null ? [] : $imagesFromFront; if (is_array($imagesFromFront)) { $dbPref = new DBPreferencesType(); $catalogPath = $dbPref->getPreference(Constants::CATALOG_PATH)[DB::TABLE_PREFERENCES__VALUE]; $mediumImageWatermarkName = $dbPref->getPreference(Constants::WATERMARK_MEDIUM_PATH)[DB::TABLE_PREFERENCES__VALUE]; $largeImageWatermarkName = $dbPref->getPreference(Constants::WATERMARK_LARGE_PATH)[DB::TABLE_PREFERENCES__VALUE]; $goodsType = new DBGoodsType(); $code = $goodsType->getCode($id); $newCode = null; if (!is_null($oldCode) && $code != $oldCode) { $newCode = $code; $code = $oldCode; } $imagesFromFileSystem = FileUtils::getFilesByPrefixByDescription(FileUtils::buildPath($catalogPath, $code), Constants::SMALL_IMAGE, "jpg"); $imagesToDelete = array_merge($imagesFromFileSystem); uasort($imagesFromFront, function ($o1, $o2) { return $o1['index'] < $o2['index'] ? -1 : 1; }); $imagesToProcessing = self::prepareImagesToProcessing($imagesFromFront, $imagesFromFileSystem, $imagesToDelete); self::removeImagesFilesBySamples(FileUtils::buildPath($catalogPath, $code), $imagesToDelete); //two steps of recreating files //step 1: rename old files to temp names (only files witch should be renamed) for ($imageIndex = 0; $imageIndex < count($imagesToProcessing); $imageIndex++) { $imageData = $imagesToProcessing[$imageIndex]; if ($imageData['new'] == 'false') { $imageNumber = FileUtils::getCatalogImageNumber($imageData['oldImage']); if ($imageNumber != null) { $smallImagePath = FileUtils::buildPath($catalogPath, $code, Constants::SMALL_IMAGE . $imageNumber . '.jpg'); $smallImageTmpPath = FileUtils::buildPath($catalogPath, $code, Constants::SMALL_IMAGE . $imageData['tempName']); rename($smallImagePath, $smallImageTmpPath); $mediumImagePath = FileUtils::buildPath($catalogPath, $code, Constants::MEDIUM_IMAGE . $imageNumber . '.jpg'); $mediumImageTmpPath = FileUtils::buildPath($catalogPath, $code, Constants::MEDIUM_IMAGE . $imageData['tempName']); rename($mediumImagePath, $mediumImageTmpPath); $largeImagePath = FileUtils::buildPath($catalogPath, $code, Constants::LARGE_IMAGE . $imageNumber . '.jpg'); $largeImageTmpPath = FileUtils::buildPath($catalogPath, $code, Constants::LARGE_IMAGE . $imageData['tempName']); rename($largeImagePath, $largeImageTmpPath); } } } //step 2: rename to real names (old files and new) for ($imageIndex = 0; $imageIndex < count($imagesToProcessing); $imageIndex++) { $imageData = $imagesToProcessing[$imageIndex]; if ($imageData['new'] == 'false') { //if image ISN'T NEW $smallImageTmpPath = FileUtils::buildPath($catalogPath, $code, Constants::SMALL_IMAGE . $imageData['tempName']); $smallImageNewPath = FileUtils::buildPath($catalogPath, $code, Constants::SMALL_IMAGE . $imageData['newName'] . '.jpg'); rename($smallImageTmpPath, $smallImageNewPath); $mediumImageTmpPath = FileUtils::buildPath($catalogPath, $code, Constants::MEDIUM_IMAGE . $imageData['tempName']); $mediumImageNewPath = FileUtils::buildPath($catalogPath, $code, Constants::MEDIUM_IMAGE . $imageData['newName'] . '.jpg'); rename($mediumImageTmpPath, $mediumImageNewPath); $largeImageTmpPath = FileUtils::buildPath($catalogPath, $code, Constants::LARGE_IMAGE . $imageData['tempName']); $largeImageNewPath = FileUtils::buildPath($catalogPath, $code, Constants::LARGE_IMAGE . $imageData['newName'] . '.jpg'); rename($largeImageTmpPath, $largeImageNewPath); } else { //if image IS NEW $data = str_replace('data:image/jpeg;base64,', '', $imageData['oldImage']); $data = str_replace(' ', '+', $data); $smallImageName = FileUtils::buildPath($catalogPath, $code, Constants::SMALL_IMAGE . $imageData['newName'] . '.jpg'); if (file_put_contents($smallImageName, base64_decode($data)) == true) { $imageEditorS = new ImageEditor($smallImageName); $imageEditorS->resizeImage(Constants::SMALL_IMAGE_WIDTH, Constants::SMALL_IMAGE_HEIGHT); $imageEditorS->saveImage($smallImageName, 100); } $mediumImageName = FileUtils::buildPath($catalogPath, $code, Constants::MEDIUM_IMAGE . $imageData['newName'] . '.jpg'); if (file_put_contents($mediumImageName, base64_decode($data)) == true) { $imageEditorS = new ImageEditor($mediumImageName); $imageEditorS->resizeImage(Constants::MEDIUM_IMAGE_WIDTH, Constants::MEDIUM_IMAGE_HEIGHT); $imageEditorS->applyWatermark($mediumImageWatermarkName); $imageEditorS->saveImage($mediumImageName, 100); } $largeImageName = FileUtils::buildPath($catalogPath, $code, Constants::LARGE_IMAGE . $imageData['newName'] . '.jpg'); if (file_put_contents($largeImageName, base64_decode($data)) == true) { $imageEditorS = new ImageEditor($largeImageName); $imageEditorS->resizeImage(Constants::LARGE_IMAGE_WIDTH, Constants::LARGE_IMAGE_HEIGHT); $imageEditorS->applyWatermark($largeImageWatermarkName); $imageEditorS->saveImage($largeImageName, 100); } } } //if good KEY_ITEM was CHANGED if (!is_null($newCode)) { rename(FileUtils::buildPath($catalogPath, $code), FileUtils::buildPath($catalogPath, $newCode)); } } }
<?php /** * The frame that contains the image to be edited. * @author Wei Zhuo * @author Paul Moers <*****@*****.**> - watermarking and replace code + several small enhancements <http://www.saulmade.nl/FCKeditor/FCKPlugins.php> * @version $Id: editorFrame.php,v 1.7 2006/12/20 18:19:28 thierrybo Exp $ * @package ImageManager */ require_once 'config.inc.php'; require_once 'Classes/ImageManager.php'; require_once 'Classes/ImageEditor.php'; //default path is / $relative = '/'; $manager = new ImageManager($IMConfig); $editor = new ImageEditor($manager); // process any uploaded files $imageRelative = $manager->processUploads(); // get image info and process any action $imageInfo = $editor->processImage($imageRelative); ?> <!--[if IE]> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <![endif]--> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $IMConfig['language']; ?> " lang="<?php echo $IMConfig['language']; ?> ">
<?php include_once '../lib/ImageEditor.php'; // create destination image $dst = new ImageEditor(); // assing canvas size $dst->createCanvas(250, 200); // filenames $src1FileName = 'all4.jpg'; $src2FileName = 'bart.jpg'; $src3FileName = 'splash.jpg'; $src4FileName = 'water.jpg'; /** * drop the sourcefiles resized into destination image */ // src1 $src1 = new ImageEditor(); $src1->loadImageFile($src1FileName); $dst->fillinArea($src1, 0, 0, 150, 100); // src2 $src2 = new ImageEditor(); $src2->loadImageFile($src2FileName); $dst->fillinArea($src2, 0, 100, 150, 100); // src3 $src3 = new ImageEditor(); $src3->loadImageFile($src3FileName); // apply drift of cropping mask to the left(x-direction) $dst->fillinArea($src3, 150, 0, 100, 100, 50, 0); // src4 $src4 = new ImageEditor(); $src4->loadImageFile($src4FileName);
} if (!file_exists($file_local)) { error_gif('Файл не найден.'); } // Узнаём размеры и формат $imSize = @GetImageSize($file_local); if (!$imSize) { error_gif('Необходимо указать файл в формате JPG, GIF или PNG.'); } if ($imSize[0] * $imSize[1] > $MaxSize * 1024000) { error_gif('Фото слишком большое. Максимальный размер - ' . $MaxSize . ' Мегапикселей.'); } if ($flag_ok == 0) { error_gif('Извините, превью не сгенерировано администратором.'); } $editor = new ImageEditor($file_local); if (!$editor->ready) { error_gif('Не удалось открыть файл.'); } if (!$w) { $editor->resizeToHeight($h); } elseif (!$h) { $editor->resizeToWidth($w); } else { $editor->resize($w, $h, $fitInside); } ob_start(); // Чтобы далее узнать точный размер файла $editor->output(); header_img(2, ob_get_length(), time(), substr($file_name, 0, 20) . '.jpg'); ob_end_flush();