PHP - Get raw image data from image in a HTML document
How do i properly grab an image that is displayed in a HTML document and feed it to PHP to be read as image binary. I do not have direct access to the image file. The image i am trying to grab is fed to the client with HTML via PHP and printed in HTML format and using an<img>
tag to display the image. The src is just a link to the same page i am currently on. The link is a GET request.
The link looks like this:
GETIMAGE.php?type=small&path=/path/to/image.png
This does not return the actual image with image MIME types. But rather a HTML displaying the image.
I do not have access to the source code in GETIMAGE.php file. This is encrypted as i am using a portal solution that is licensed.
This is the source that is returned from the GETIMAGE.php script:
<html>
<head>
<meta name="viewport" content="width=device-width">
<title>GETIMAGE.php (80×112)</title>
<style type="text/css"></style>
</head>
<body >
<img src="http://portal.craftnordic.com/PORTAL/GETIMAGE.php?type=small&path=Path/To/Image.png">
</body>
Answer
Solution:
Without seeing your script, it is hard to figure out what you are looking for. Let's assume the page generates output like this:
Using this excellent DOM Parsing Library, we can do something like this:
Then you will have an array of all pictures in
$pictures
.Good luck.
Answer
Solution:
You can use file_get_contents() method to get the data.
Here you can use
Answer
Solution:
Don't know if you ever found an answer, but I finally did. The data that was being received by file_get_contents - or any CURL method - was actually returning data in a gzip format. When I saved the output to a file and extracted it as a gzip archive, the image was there.