* Elgg tidypics library of resizing functions\r
* \r
*/\r
+ \r
+ include dirname(__FILE__) . "/watermark.php";\r
\r
\r
/**\r
*/\r
function tp_create_imagick_cmdline_thumbnails($file, $prefix, $filestorename)\r
{\r
- global $CONFIG;\r
- \r
- $mime = $file->getMimeType();\r
- \r
$image_sizes = get_plugin_setting('image_sizes', 'tidypics');\r
if (!$image_sizes) {\r
register_error(elgg_echo('tidypics:nosettings'));\r
- return array();\r
+ return false;\r
}\r
$image_sizes = unserialize($image_sizes);\r
+\r
+ $thumb = new ElggFile();\r
+\r
+\r
+ // tiny thumbnail\r
+ $thumb->setFilename($prefix."thumb".$filestorename);\r
+ $thumbname = $thumb->getFilenameOnFilestore();\r
+ $rtn_code = tp_imagick_cmdline_resize( $file->getFilenameOnFilestore(),\r
+ $thumbname,\r
+ $image_sizes['thumb_image_width'],\r
+ $image_sizes['thumb_image_height'], \r
+ true);\r
+ if (!$rtn_code)\r
+ return false;\r
+ $file->thumbnail = $prefix."thumb".$filestorename;\r
+\r
+\r
+ // album thumbnail\r
+ $thumb->setFilename($prefix."smallthumb".$filestorename);\r
+ $thumbname = $thumb->getFilenameOnFilestore();\r
+ $rtn_code = tp_imagick_cmdline_resize( $file->getFilenameOnFilestore(),\r
+ $thumbname,\r
+ $image_sizes['small_image_width'],\r
+ $image_sizes['small_image_height'], \r
+ true); \r
+ if (!$rtn_code)\r
+ return false;\r
+ $file->smallthumb = $prefix."smallthumb".$filestorename;\r
+\r
+\r
+ // main image\r
+ $thumb->setFilename($prefix."largethumb".$filestorename);\r
+ $thumbname = $thumb->getFilenameOnFilestore();\r
+ $rtn_code = tp_imagick_cmdline_resize( $file->getFilenameOnFilestore(),\r
+ $thumbname,\r
+ $image_sizes['large_image_width'],\r
+ $image_sizes['large_image_height'], \r
+ false); \r
+ if (!$rtn_code)\r
+ return false;\r
+ $file->largethumb = $prefix."largethumb".$filestorename;\r
\r
- $thumblarge = tp_imagick_cmdline_resize($file->getFilenameOnFilestore(), \r
- "largethumb", \r
- $image_sizes['large_image_width'], \r
- $image_sizes['large_image_height'], \r
- false); \r
- \r
- $thumbsmall = tp_imagick_cmdline_resize($file->getFilenameOnFilestore(), \r
- "smallthumb", \r
- $image_sizes['small_image_width'], \r
- $image_sizes['small_image_height'], \r
- true); \r
-\r
- $thumbnail = tp_imagick_cmdline_resize($file->getFilenameOnFilestore(), \r
- "thumb", \r
- $image_sizes['thumb_image_width'], \r
- $image_sizes['thumb_image_height'], \r
- true);\r
- \r
- if ($thumbnail) {\r
- $thumb = new ElggFile();\r
- $thumb->setMimeType($mime);\r
- $thumb->setFilename($prefix."thumb".$filestorename);\r
- $file->thumbnail = $prefix."thumb".$filestorename;\r
- }\r
- \r
- if ($thumbsmall) {\r
- $thumb = new ElggFile();\r
- $thumb->setMimeType($mime);\r
- $thumb->setFilename($prefix."smallthumb".$filestorename);\r
- $file->smallthumb = $prefix."smallthumb".$filestorename;\r
- }\r
- \r
- if ($thumblarge) {\r
- $thumb = new ElggFile();\r
- $thumb->setMimeType($mime);\r
- $thumb->setFilename($prefix."largethumb".$filestorename);\r
- $file->largethumb = $prefix."largethumb".$filestorename;\r
- }\r
+ \r
+ //tp_watermark($thumbs);\r
+ \r
+\r
\r
- return array( "thumbnail" => $thumbnail,\r
- "thumbsmall" => $thumbsmall,\r
- "thumblarge" => $thumblarge);\r
+ unset($thumb);\r
+\r
+ return true;\r
}\r
\r
/*\r
* (Returns false if the uploaded file was not an image)\r
*\r
* @param string $input_name The name of the file input field on the submission form\r
- * @param string $prefix The text to prefix to the existing filename\r
+ * @param string $output_name The name of the file to be written\r
* @param int $maxwidth The maximum width of the resized image\r
* @param int $maxheight The maximum height of the resized image\r
* @param true|false $square If set to true, will take the smallest of maxwidth and maxheight and use it to set the dimensions on all size; the image will be cropped.\r
- * @return false|mixed The contents of the resized image, or false on failure\r
+ * @return bool\r
*/\r
- function tp_imagick_cmdline_resize($input_name, $prefix, $maxwidth, $maxheight, $square = false, $x1 = 0, $y1 = 0, $x2 = 0, $y2 = 0) {\r
-\r
- $params = array(\r
- "input_name"=>$input_name,\r
- "output_name"=>$output_name,\r
- "maxwidth"=>$maxwidth,\r
- "maxheight"=>$maxheight,\r
- "square"=>$square,\r
- "x1"=>$x1,\r
- "y1"=>$y1,\r
- "x2"=>$x2,\r
- "y2"=>$y2);\r
+ function tp_imagick_cmdline_resize($input_name, $output_name, $maxwidth, $maxheight, $square = false, $x1 = 0, $y1 = 0, $x2 = 0, $y2 = 0) {\r
\r
- $path = pathinfo($input_name);\r
- $output_name = $path["dirname"] . "/$prefix" . $path["filename"] . "." . $path["extension"];\r
\r
// Get the size information from the image\r
if ($imgsizearray = getimagesize($input_name)) {\r
\r
$accepted_formats = array(\r
'image/jpeg' => 'jpeg',\r
+ 'image/pjpeg' => 'jpeg',\r
'image/png' => 'png',\r
+ 'image/x-png' => 'png',\r
'image/gif' => 'gif'\r
- );\r
+ );\r
// If it's a file we can manipulate ...\r
if (array_key_exists($imgsizearray['mime'],$accepted_formats)) {\r
\r
if(substr($im_path, strlen($im_path)-1, 1) != "/") $im_path .= "/";\r
$command = $im_path . "convert \"$input_name\" -resize ".$newwidth."x".$newheight."^ -gravity center -extent ".$newwidth."x".$newheight." \"$output_name\"";\r
exec($command);\r
- return $output_name;\r
+ return true;\r
\r
}\r
}\r