/** * Automatically convert the uploaded file to a web-compatible type. Uses * only the first image of multi-page uploads (like PDFs) and populates the * _target_mimetype member accordingly. The original_tmpname file is manipulated * directly. * * Uploaded GIF, PNG and JPEG files are left untouched. * * In case of any conversions being done, the new extension will be appended * to the uploaded file. * * @return boolean Indicating success */ function _auto_convert_to_web_type() { debug_add("\$this->_original_mimetype: {$this->_original_mimetype}"); switch ($this->_original_mimetype) { case 'image/png': case 'image/gif': case 'image/jpeg': $this->_target_mimetype = $this->_original_mimetype; $conversion = null; break; case 'application/postscript': case 'application/pdf': $this->_target_mimetype = 'image/png'; $conversion = 'png'; break; default: $this->_target_mimetype = 'image/jpeg'; $conversion = 'jpg'; break; } debug_add("\$conversion={$conversion}"); if (empty($conversion)) { return true; } if (!midcom_helper_imagefilter::imagemagick_available()) { throw new midcom_error('DM2 type image requires ImageMagick for manipulation operations, see debug log for details'); } // PONDER: Make sure there is only one extension on the file ?? $this->_filename .= ".{$conversion}"; return $this->_filter->convert($conversion); }
function imagemagick_available($raise_uimessage = false) { if (!$this->check_imagemagic) { return true; } $ret = midcom_helper_imagefilter::imagemagick_available(); if (!$ret && $raise_uimessage) { midcom::get('uimessages')->add($this->_l10n->get('midcom.helper.datamanager2'), 'ImageMagick is required but seems not to be available, image fields may be disabled', 'error'); } return $ret; }