Imagecopyresampled Tangled for a long time, seeking expert assistance.
Test code:
$CREATEIMG = imagecreatefromjpeg (' x.jpg ');//Picture size is 200*150
$newimg = Imagecreatetruecolor (200,150);
Imagejpeg ($NEWIMG);
Several parameter values read the manual, presumably understanding their role. Only some of the parameters have been tested and are not expected to be effective.
Original:
Like what:
1. Set $end _w=200, $end _h=150 is the width and height of the source file, I set it to $end _w=400, $end _h=300; As I understand it, enlarge the image and then indent it to 300*150, and set it to $end_w=200, $end _H=150 is the same.
:
After setting the surprise, the high and wide became 100*75; I think it is because this function is passed, the height of the setting of the original image and the width of the new graph to calculate the ratio of the height. And then by the original figure of the actual width of the respective addition to this ratio generated.
And I will $end_w=200, $end _h=150 setting a value smaller than the original is another case. For example, set to $end_w=100, $end _h=150
The. function intercepts the truncated image by 100 and then pulls it up to 200.
:
2. Set $start _w=0, $start _h=12.5 wanted to press the picture into 100*75 to intercept the high 50 middle part. Set up
$newimg = Imagecreatetruecolor (100,50);
Imagecopyresampled ($newimg, $CREATEIMG, 0,0, $start _w=0, $start _h=24.5, $width =100, $height =75, $end _w=200, $end _h=150 )
Generated image is the original 24.5 re-pressure, the bottom of the extra 24.5 is limited by the size of the canvas is not visible, to achieve the desired goal. I don't know if this is the right way to implement.
:
Pressed to become 100*75 in the 75/2 calculated by the two sides of the intercept 12.5 should be the same, I do not know whether it can be achieved.
Just contact This function soon, we have more suggestions, the more wordy the better. Thank you all first!
------Solution--------------------
You're going to have to zoom in on the original version.
This will only mislead you.
The original only 200*150
Then (201, 1) must be on the outside of the diagram
The graph doesn't get bigger, it's just that you're taking values out of the map.