Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 5 of 5 total
Thread load image by serverRequest
Tue, Sep 1 2020 4:56 AMPermanent Link

Martin Pflug

Hello,

EWB 2.06 Build 20

Is there a way to load an image by using ServerRequest?

I need ist, because i have to manipulate an image.
The image is stored in a directory at the server.
I tried to call a php-file by using the post-mode (the image-url).
The php code manipulate the image and return it:

<?php
// ... some code
   header("Content-type: image/JPEG");
   $img=imagecreatefromjpeg($path);
// here is my manipulation
// ... some code
// and the return
   imagejpeg($img);
?>

I know that works outside of ewb. But now i want to show this manipulated picture in TImage.
OK, i could save it on the harddisk and call it by url.
But the image is still in memory and i hope there is a direct way.
Maybe something like this: "Image.loadFrom(Memory)Stream"

many thanks
Tue, Sep 1 2020 11:52 AMPermanent Link

Matthew Jones

You can't do that on the browser side, but you could set the image URL to be something that causes the action you want, so something like "myimage.png?resize=small" or something.

--

Matthew Jones
Wed, Sep 2 2020 1:30 AMPermanent Link

Martin Pflug

"Matthew Jones" wrote:

You can't do that on the browser side, but you could set the image URL to be something that causes the action you want, so something like "myimage.png?resize=small" or something.

--

Matthew Jones



...I do not understand that.
(myimage.png?resize=small)
Who should change the size now? Can you give me an example, please?

Thank you

Martin Pflug
Wed, Sep 2 2020 4:07 AMPermanent Link

Matthew Jones

You have PHP that is doing some image manipulation - you can trigger that using the image URL of TImage. Or, you can pick up the results of another process. But you need to learn the relationship between your browser and the server and the requests.

--

Matthew Jones
Wed, Sep 2 2020 5:59 AMPermanent Link

Martin Pflug

"Matthew Jones" wrote:

You have PHP that is doing some image manipulation - you can trigger that using the image URL of TImage. Or, you can pick up the results of another process. But you need to learn the relationship between your browser and the server and the requests.

--

Matthew Jones


OK, now i understand. Thank you

I've tried it, ... it works.
Maybe someone else need this also.
Here is my solution:
In the image url i call a php-file with get-mode: "/path/myphp.php? name = test.jpg"

And this is my php file:

<?php
if (isset ($_GET['name'])) $name_path = $_GET['name'];
// At this time i don't know the image type
$type=getimagesize ($name_path) or die('Unknown');

// LOAD
switch ($type[2])
{
   case 1: // GIF
   $img=imagecreatefromgif($name_path);
   break;
   case 2: // JPEG
   $img=imagecreatefromjpeg($name_path);
   break;
   case 3: // PNG
   $img=imagecreatefrompng($name_path);
}

// Do something with the image

// and then RETURN
switch ($type[2])
{
   case 1: // GIF
   imagegif($img);
   break;
   case 2: // JPEG
   imagejpeg($img);
   break;
   case 3: // PNG
   imagepng($img);
}

// DESTROY
imagedestroy($img);
?>

Martin Pflug
Image