Jump to content

phippu

Members
  • Posts

    13
  • Joined

  • Last visited

About phippu

  • Birthday 11/01/1988

Profile Information

  • Gender
    Male

Recent Profile Visitors

1,168 profile views

phippu's Achievements

Jr. Member

Jr. Member (3/6)

6

Reputation

  1. phippu

    Form

    Thank you very much! That's very logic, but wasn't aware of this behavior... It's now working! shouldn't this php method be implemented in Textarea? Just a thought...
  2. phippu

    Form

    Sorry I forgot an important detail, it was a little bit late yesterday @kixe I tried this "multiline" option. Unfortunately it doesn't work. I also tried the following code: $message = $form->get("message")->value; $message does not contain newline characters, so I suspect to set an option in this code: $field = $modules->get("InputfieldTextarea"); $field->label = "Nachricht"; $field->attr('id+name','message'); $field->required = 1; $form->append($field); // append the field to the form
  3. phippu

    Form

    Hello everyone! I'm stumbling upon a form, again... I'm trying to get the Text out of my Form with the newline characters. I'm using PW 2.5.3 What I have in Code a little bit cut down: $form = $modules->get("InputfieldForm"); $form->action = "./"; $form->method = "post"; $form->attr("id+name",'subscribe-form'); // create a textarea input for the actual message $field = $modules->get("InputfieldTextarea"); $field->label = "Nachricht"; $field->attr('id+name','message'); $field->required = 1; $form->append($field); // append the field to the form // form was submitted so we process the form if($input->post->submit) { $message = $sanitizer->textarea($form->get("message")->value); $out .= "<strong>Nachricht:</strong></br>"; $out .= $message."</p>"; } else { // render out form without processing $out .= $form->render(); } I can't get it with newlines, what am I doing wrong? Thanks in advance for your support
  4. I'm feeling ashamed guys. Sorry, it was on 2.7.2. I was on branch master not devns
  5. Hello As I remember I pulled the newest version from GitHub before I tried to install the module. I will check the exact installed version this evening.
  6. Hi ngrmm You probably tried to upload an image that has too many pixels, so your allocated memory to PHP is not enough to process your image. I advise you to get that line back in... Your images will look strange without it at some point. You have two options if my assumption is correct: 1. Increase the PHP memory to the maximum 2. if that doesn't help, shrink your images before uploading them. Hope this still helps
  7. Hello! I read a lot about the ImageSizer class from processwire, because I want to contribute to get better image resizing. Processwire (horst in special) has implemented a gamma correction before resizing images. Why this has to be done is explained here: http://www.4p8.com/eric.brasseur/gamma.html . I have this link also from a post from Horst. Now I stumbled upon a bug that causes to loose image information. This is the function I am talking about in ImageSizer.php protected function gammaCorrection(&$image, $mode) { if(-1 == $this->defaultGamma || !is_bool($mode)) return; if($mode) { // linearizes to 1.0 if(imagegammacorrect($image, $this->defaultGamma, 1.0)) $this->gammaLinearized = true; } else { if(!isset($this->gammaLinearized) || !$this->gammaLinearized) return; // switch back to original Gamma if(imagegammacorrect($image, 1.0, $this->defaultGamma)) unset($this->gammaLinearized); } } This function uses the gd-lib function imagegammacorrect to set the gamma value to 1.0 before resizing and set it back after resizing. The imagegammacorrect function provides a datatype int, which has on my server the size of 8 bits, just enough to store a picture that also stores each pixel in 8 bit value. What the imagegammacorrect function does: It exponentiates each pixel-value of the image with the gamma value entered (2.0 by default on pwire). Then it resizes the image. After that to set back the gamma it exponantiates with the inverse value that was before exponentiated. (1/2.0=0.5 with default value). Because only integer (8bits) is provided the function is rounding the values and makes some error. Here is my test picture (2400x2400 pixels) I resized every image to 300x300 pixels. Here are the resized ones with different gamma values: Gamma function omitted Gamma value 2.0 (standard) Gamma value 3.0 Gamma value 4.0 Now I was curious if I could reconstruct the error in an other program. So I wrote a little script in Matlab and did the same. Heres the script: % load image [img,map,alpha] = imread('gamma_dalai_lama_gray.jpg'); %imshow(img, 'InitialMagnification', 100); gamma = 2; scale_factor = 300/2400; figure(1); imshow(img, 'InitialMagnification', 200); figure(2); tmp = double(img).^gamma; img_gamma = uint8(tmp./((255^gamma)/255)); img_resized = imresize(img_gamma, 0.5); tmp2 = double(img_resized).^(1/gamma); img_gamma = uint8(tmp2./((255^(1/gamma))/255)); imshow(img_gamma, 'InitialMagnification', 400); imwrite(img_gamma, 'testbild_300_gamma_2.0.jpg'); Here's the result pictures: Gamma value 2.0 (with matlab) Gamma value 3.0 (matlab) Gamma value 4.0 (matlab) Theoretical we would need more than 8bits per pixel to not loose any data. That would be for Gamma 4.0: (2^8)^4=32bits per pixel. Or for Gamma 2.0: (2^8)^2=16bits per pixel. I don't know how to solve this problem in php so I'm writing in here in the hope someone has a good solution or a hint what I'm doing wrong... Processwire Version 2.5.3 PHP-Version is 5.6.0 If you need more informations let me know. Edit: My integer size has not the size of 8bits that was 8bytes so 64bits... But as I confirmed with matlab script there is an 8bit cropping going on, maybe in the gd-lib? Edit: I think I found out where this is caused. It's in the php sources (php-src/ext/gd/gd.c on line 3133). The cropping happens, because an integer is used instead of a double or float value (the dark pattern in my test image gets even darker with gamma correction). My suggestion is to take out the Gamma Correction and contribute code to GD-Lib to implement it there. With plain php we can't make it better for now.
  8. I know what you mean but what at the moment is done by processwire is: Call the imagecopyresampled function. This function does something like (when making an image smaller):​ Convolution with a specific matrix (gaussian or box-blur) to blur it. This is the anti-aliasing filter to prevent some strange pattern in the picture Take pixels from that blury image and delete those who are not needed. The picture should (in theory) look not blurred because of the downsampling. But to get the best performance, the algorithms make a compromised solution, so a little aliasing patterns appear and it look sharp. ​Then Processwire does Sharpening. Sharpening is nothing else than doing a deconvolution to that downsampled picture with the (in theory) same matrix as in point 1.1. That means the Anti-Aliasing effect is gone and the picture looks like it never had filtering (which indeed is needed!) So this filtering could be saved and all that very CPU-intensive filtering could be omitted and just a "nearest-pixel-algorithm" be used (well almost ). Here are some pictures to show what i mean: Original Test Pattern can be viewed here. It has the dimensions 2400x1800. First of all I show the same picture resized with Photoshop using the "nearest-pixel-algorithm". It is to show, that without filtering those patterns appear: Processwire with the following options: $options = array( 'quality' => 100, 'upscaling' => false, 'sharpening' => 'none', ); Processwire with the following options: $options = array( 'quality' => 100, 'upscaling' => false, 'sharpening' => 'true', ); In those test patterns we can see that the algorithm imagecopyresampled is using is not the best. But probably a good mix between speed and quality. To show how photoshop in "bicubic auto" has done its work. here it is:
  9. Well thank you for your help! maybe I'll find some time to improve the imSharpen method. I know Photoshop e.g. is also doing some sharpening at the end. The alternative to sharpening would be to use a better low-pass-filter before downsampling to not loose too much "sharpness".
  10. I agree with you that an image conversion shouldn't be default. On the other hand, it is specified to reduce the image quality and processwire doesn't do it by default (with a png image). To realise that the quality isn't reduced you have to have technical understanding whereas you do not need specific understanding to see that a transparent part of the image is missing. To the default discussion. In my oppinion it is also not very good to have an image sharpening effect as default.
  11. Thanks alot! Haven't thought of that... But it's logic that png can't have it's quality changed. I took a look in the "ImageSizer.php". Wouldn't it be great to save every picture as JPG if the Quality is not 100? That would make sense at least for me. Maybe some others also stumbled over this? Would be great to discuss if this could be implemented. Something like this (in line 358): switch($this->imageType && CheckForQuality) { case IMAGETYPE_GIF: // correct gamma from linearized 1.0 back to 2.0 $this->gammaCorrection($thumb, false); $result = imagegif($thumb, $dest); break; case IMAGETYPE_PNG: if(!$this->hasAlphaChannel()) $this->gammaCorrection($thumb, false); // always use highest compression level for PNG (9) per @horst $result = imagepng($thumb, $dest, 9); break; case IMAGETYPE_JPEG: // correct gamma from linearized 1.0 back to 2.0 $this->gammaCorrection($thumb, false); $result = imagejpeg($thumb, $dest, $this->quality); break; } /wire/core/ImageSizer.php
  12. Hello everyone! I have the problem that changing quality within picture resizing doesn't work. I'm using PW 2.5.3. The code is the following: <?php $options = array( 'quality' => 10, 'upscaling' => false, 'cropping' => 'southeast' ); $img_1x = $page->bild->first()->width(500, $options); $img_2x = $page->bild->first()->width(1000, $options); $img_3x = $page->bild->first()->width(1500, $options); include("./head.inc"); echo '<h1>'.$page->title.'</h1>'; echo '<img srcset="'.$img_1x->url.' 1x, '.$img_2x->url.' 2x, '.$img_3x->url.' 3x" src="'.$img_1x->url.'"/>'; include("./foot.inc"); To test the behaviour I deleted the resized pictures in /site/assets/ and recalled this script above. I can't see changing the quality when I'm changing the 'quality' option. I also can't see the file size changing. Can anyone lead me to the solution? Am I doing something wrong? Thanks for your kind help
  13. I have the same problem here. My ProcessWire is in version 2.4.0 and I'm running it at the moment in a XAMPP v. 3.2.1 environment. I think I could localize the error a little bit... I use a custom PHP script to get the pages I need: return $pages->find("template=basic-page|mitglieder"); If I now select also Home or any other Page up in the "Parent of selectable page(s)" section. It works only, if there is the "correct" page selected. Say my menutree looks like this: Home | Site1 |----SubSite1 | |-SubSite2 | | |-----SubSubSite1 | | |-----SubSubSite2 | | |-----SubSubSite3 | |-SubSite3 | Site2 | Site3 With my php-script I can see following Sites; Site1 SubSite1 SubSubSite1 SubSubSite2 SubSubSite3 Now the setting "Parent of selectable page(s)" is set to "SubSite2" and the php script still there. Then I can choose only the "SubSubSites" when I try to choose SubSite1 the Error "Page 1322 is not valid for some_page_name" occurs. If I want to choose SubSite1 I have to change the "Parent of selectable page(s)". I hope it is understandable what I mean , otherwise tell me. I also hope someone could reproduce this error and fix that bug. Thanks Community & Ryan for that great system! Phippu
×
×
  • Create New...