-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem with the tags versions #1
Comments
Hi Mariano, Thanks a lot! Yes stable tag is not released yet, because I'm develop it now. composer require jbzoo/image:"3.x-dev" Best regards, Denis. |
Hi Denis, i report you a little writing mistake on line 331 in the dev version: $cleanFilename = FS::clean($filename);
if (!file_exists($cleanFilename)) {
throw new Exception('Image file not forund: ' . $filename);
} And then i want suggest you to develop a feature that can be usefull: /**
* Enter description here ...
* @author Mariano.Pirelli
*
*/
class ImageMemory extends Image {
public function __construct($imageString) {
// Require GD library
if (!extension_loaded('gd')) {
throw new \Exception('Required extension GD is not loaded.');
}
if (empty($imageString)) {
throw new \Exception('Empty image string data');
}
if (function_exists('getimagesizefromstring')) {
//gather meta data
$info = getimagesizefromstring($imageString);
} else {
throw new \Exception('PHP 5.4 is required to use method getimagesizefromstring');
}
$this->cleanup();
$this->_mime = $info['mime'];
$this->_width = $info[0];
$this->_height = $info[1];
$this->_image = imagecreatefromstring($imageString);
$this->_exif = array();
$this->_orient = $this->_getOrientation();
imagesavealpha($this->_image, true);
imagealphablending($this->_image, true);
return $this;
}
} Thanks for the work. |
Yea, thanks. But I think that saving images to database is nt good idea. |
Oh yes i know...there are advantage and disadvantage.. public function getImageData($format = 'png', $quality = null)
{
if (!$this->_image) {
throw new \Exception('Image resource not defined');
}
// Output the image
ob_start();
$mimetype = $this->_renderImageByFormat($format, null, $quality);
$imageData = ob_get_contents();
ob_end_clean();
return $imageData;
} |
Great! PS I changed your comments, fixed highlight of code. |
Thank you very much. I want suggest you just another thing. i hope that this can help: I found that PHP under windows use the extension .tmp on uploaded files, included images, while others system don't use the extension. So if i use a code like this an exception will be thrown: $image = new Image($_FILES['name']['tmp_name']); // the temp file
$image->bestFit(800, 600)->save(); //save the temp file
copy($_FILES['name']['tmp_name'], $newPath); //copy the file the exception is: Undefined format. because the format is tmp. protected function _renderImageByFormat($format, $filename, $quality)
{
if (Helper::isJpeg($format)) {
} elseif (Helper::isPng($format)) {
} elseif (Helper::isGif($format)) {
} else {
throw new Exception('Undefined format: ' . $format);
}
return $result;
} so i suggest this behavior: when the method save() is called, could be better read the image format from the mime type instead from file extension, the filename is not changed so also the format, and the error above will be prevented. while on savaAs(), read like now the format from the file name extension. i hope that is comprensible what i wrote. Mariano |
Hi Mariano, I jsut pushed new version to Thanks. |
All these features available in the 3.x version. It is stable now. |
Hi Denis, |
Hi, You can use May be you can sugget me some another method to convert it to string? May be with pull request? Best regards, Denis. |
Hi, /**
* Outputs image as binary string
*
* @param null|string $format If omitted or null - format of original file will be used, may be gif|jpg|png
* @param int|null $quality Output image quality in percents 0-100
* @return string
*
* @throws Exception
*/
public function getImageData($format = 'gif', $quality = null) or
public function getImageString($format = 'gif', $quality = null) or
public function getImageBinary($format = 'gif', $quality = null)
{
if (!$this->_image) {
throw new Exception('Image resource not defined');
}
// Output the image
ob_start();
$mimetype = $this->_renderImageByFormat($format, null, $quality);
$imageData = ob_get_contents();
ob_end_clean();
return $imageData;
} |
Hi mapirelli, Try to use getBinary() from v3.0.2 |
Hi Denis, thank you very much. |
You are welcome :) |
Hi,
this porting is very usefull, i love the new methods, but i found that the tag version 3.0.* released differs from the master and the documentation.
I downloaded the library with composer
Mariano
The text was updated successfully, but these errors were encountered: