Jump to content

horst

PW-Moderators
  • Posts

    4,064
  • Joined

  • Last visited

  • Days Won

    87

Everything posted by horst

  1. The next version of PiM will be able to enhance the Thumbnails module (after I have successful send a pull request to apeisa and he have had time to check and implement the code, - hopefully) While writing on the (optional) support for PiM with Thumbnails, owzim has written the js-code that rebuilds the crop rectangle, - and also he has tested and forthrightly commented my various tests with that. Thumbnails will recognize if PiM is installed and use a different routine then. And without PiM the Thumbnails Module will use the PW core ImageSizer. Since dev-version 2.3.3 the ImageSizer uses automatic sharpening after resize. So - once after updating to the new module and a newer PW version (dev 2.3.3 or stable 2.4) everyone has sharpening support. We both (owzim & me) want to have the coords & data stored and pre-selected when coming back to a previous created thumbnail. We use a wrapper class with a read and a write method on a session basis to achieve that. (After closing the browser or otherwise destroy the session, all data is lost) But together with PiM the coords and options can be stored permanent! It can be stored as metadata in a IPTC custom field (2#215) with the original imagefile. If you want enable permanent storage you have to create a config array named imageManipulatorOptions in your site/config.php and create the key thumbnailCoordsPermanent and set it to true: $config->imageManipulatorOptions = array( // ... 'thumbnailCoordsPermanent' => true ); So, - if you don't want permanent storage, you are still able to use Thumbnails Module and PiM together, but without permanent storage. https://youtu.be/IHwjL7YSfRo EDIT: PullRequest is send https://github.com/apeisa/Thumbnails/pull/13 (the unorthodox way)
  2. Ryan, wouldn't it be better to check if the current available memory is enough for a image resize? If we restrict it in the config.php for 32M, all above that (64M, 128M, 256M, ...) have to change the setting. And if they don't know it, they first run into the limitation. I think if we try to find a point for the maximum we have to guess how much RAM PW has allocated before the call to image resize. I don't know how much memory PW allocated for a 'normal' ? request, but lets say it would be something like 14M for example, we have 18M for the image resize. We need memory for the source image and for the target image plus memory for the image operation(s). - lets use a factor 2.5 18 / factor 2.5 = 7.200.000 / 3 (channels RGB) = 2.400.000 (this would be the setting for the config.php)! This could be a image of 1250 x 1920 px. But it will crash if PW has allocated 15M and not 14M. That said, one possible way (without a setting in config.php) could be to check the available memory: function checkMemoryForImage($imageFilename) { // images pixel $size = getimagesize($imageFilename); $imgPix = $size[0] * $size[1]; // read PHP maxMemory from php.ini $sMem = trim(ini_get('memory_limit')); preg_match('/^[0-9].*([k|K|m|M|g|G])$/', $sMem, $match); $char = isset($match[1]) ? $match[1] : ''; switch(strtoupper($char)) { case 'G': $maxMem = intval(str_replace(array('G','g'),'',$sMem)) * 1073741824; break; case 'M': $maxMem = intval(str_replace(array('M','m'),'',$sMem)) * 1048576; break; case 'K': $maxMem = intval(str_replace(array('K','k'),'',$sMem)) * 1024; break; default: $maxMem = intval($sMem); } // read current allocated memory $curMem = memory_get_usage(true); // memory_get_usage() always is available with PHP since 5.2.1 // check if we have enough RAM to resize the image if($maxMem - $curMem > 2.5 * $imgPix) { return true; } return false; } The code is meant as example. There should be only one call per Request (or per Session?) to the php.ini to get the maxMem, and not one call per image resize, etc.
  3. Hi Henning, I think you have the wrong param for opacity. PHP.net says: function imagecolorallocatealpha param alpha: A value between 0 and 127. 0 indicates completely opaque while 127 indicates completely transparent. Please try with child->image2->pimLoad('wh', true)->canvas(195, 193, array(0, 0, 0, 127), "centered", 0)->pimSave()->url; EDIT: @Henning: I have noticed that the common way to define a rgba color is 0-255 for R, G and B and a float value between 0 and 1 for the alpha channel (opacity). 0 is transparent and 1 is opaque. I think it is better to use the common way with float 0-1 as param and convert it internally to suite the need of the GD-lib. The change will go into the module version 0.0.8 and I will release it later this weekend.
  4. something like this: $im = new ImageSizer($targetPath); $im->resize($targetWidth, $targetHeight); //or $im->width($targetWidth, $options); // $options are optional!
  5. As I can see both sides and maybe some more facettes, I like this: taken from here, the answer to question number 5)
  6. The classnames are following the nameing conventions, but the descriptions not all. I would like the name Thumbnail in front of all 3 descriptions because it is known as "the Thumbnails module"!
  7. It is possible to define a maximum number of allowed pixel (like Megapixel) somehow and it can be checked before loading the imagefile into memory with the getimagesize function: $size = getimagesize($filename); $maxPix = $size[0] * $size[1];
  8. <maybe-this-helps>http://processwire.com/talk/topic/4096-how-to-translate-text-containing-html-tags/#entry40116</maybe-this-helps>
  9. @Wanze: they have wide support for HTML and CSS: http://processwire.com/talk/topic/4338-how-to-include-mpdf/#entry42512 and also using different fonts is easy. Don't know TCPDF, but have read there docs and can't remember of such wide support for CSS / HTML. ?
  10. @Manol: that's a good find. They have wide support for HTML and CSS and also using different fonts is just a snap.
  11. @WillyC: thanks for pointing to it. without maybe I could forget the varied features of the forum software (SCNR)
  12. Pete, at the "New content" view the button hasn't the pid of the post in the link-href like it has it in all other forum sections. (... &section=findpost&pid= )
  13. Note: when I try use the filter, I don't get PW with: /dir/cms/free/php/ only with: /dir/cms/open-source/php/ There are other open source cms also listed with the free filter, PW not. Why?
  14. You can set set_time_limit(30); within the foreach-loop. That way you have higher settings only with that script, not with the whole server. EDIT: If you need for what ever reason a check you can do it at your own: $start = time(); $maxallowed = 600; foreach($somethings as $something) { // ... your code set_time_linit(10); // reset the countdown for every loop! if(time() > ($start + $maxallowed)) { // check the max executed time of the script // break or exit or whatever } }
  15. Yeah, I remember back 15 years or some more, - we have compressed very large images with jpeg quality 1 to a minimum filesize and have send it per Email to recipients where the needed RAM of the uncompressed image was higher than their available system memory!
  16. @MadeMyDay: I think filesize doesn't matter, like owzim said: important is the needed RAM for the uncompressed image. @owzim: I think you are right (to 95%), but the timeout can matter too. EDIT: @MadeMyDay: PHP: settings for post_max_size & upload_max_filesize can be an option! (If the customers / clients and their coworkers ignore advise, you have to push them harder!)
  17. @MadeMyDay: ok, you may look here and try it if it solves your issues too: http://processwire.com/talk/topic/3718-lots-of-images-to-resize-timeout-in-frontend/?p=36291 (this post and above) Also have edited first post! (php memory usage!)
  18. Hi MadeMyDay, you can define allready a max size for uploaded images in the admin for the (crop)-images field under setup fields (your image field) input: This way there is only one resize with the big image version. Following resizes are faster. EDIT: Additionally you may try to bump up the allowed memory usage for php to 128MB or 256MB: in htaccess: php_value memory_limit 128M or 256MB
  19. Other then in imagemagick, i don't see a ton of functions and filters in there I think to autoadjust something there is always a portion of guessing with it - or 'out-rider' pixels that screw up or down the autoadjusted result into false directions. I never use such tools without a manually visually control. Also with captureOne and photoshop I do not use those with batch editing.
  20. A bit Very bizzare! - So, if he (the author of json.org) doesn't know: what maybe good for one maybe evil for another one at the same time.
  21. @soma: I think not seriously. (I haven't heard of that.) https://www.google.com/search?q=gd+php+autoadjust%3F
  22. hoi, there are now two 'unplanned' additions in the Version 0.0.5: canvas($width, $height, $bgcolor, $position, $padding) $width = mixed, associative array with options or integer, mandatory! $height = integer, mandatory if $width is integer! $bgcolor = array with rgb or rgba, - default is 255, 255, 255 $position = one out of north, northwest, center, etc, - default is center $padding = integer as percent of canvas length, - default is 0 unsharpMask($amount=100, $radius=0.5, $threshold=3) // its the same like the method in Photoshop, credit goes to: Torstein Hønsi for the unsharp mask algorithm (created in 2003 - p h p U n s h a r p M a s k)! ..., can create better results than the default stepResize!
  23. @diogo: width & height & BG as rgba is ok! But for what is x- and y-position? I have thought one want to center it into the canvas. If you think it make sence to position out of the center, I think it could be better to use the north, northwest, center, etc position and a $padding (I would prefer in percent), that would be most consistent way with other methods. What do you think?
×
×
  • Create New...