Re: do I use fopen or fsockopen to get an image as a stream of bytes?




Andy Hassall wrote:
> On 4 Nov 2005 09:42:55 -0800, lkrubner@xxxxxxxxxxxxx wrote:
>
> >How do I get an image like that, as a stream of bytes? Which function
> >do I use?
>
> Where are you getting it from?
> What format is the image in?
>
> You probably want a sequence of:
>
> http://uk.php.net/file_get_contents - get the image from a file or URL
>
> http://uk.php.net/imagecreatefromstring - create a GD image object
>
> http://uk.php.net/manual/en/function.imagesx.php
> http://uk.php.net/manual/en/function.imagesy.php
> http://uk.php.net/manual/en/function.imagecolorat.php

That's awesome. I tried the following and I got a long list of numbers
8 digits long.

$myFileAsString =
file_get_contents("http://www.mycompany.com/product_images/composite_standard_sm/318_1_SM_100.jpg";);

$image = imagecreatefromstring($myFileAsString);

$width = imagesx($image);
$height = imagesy($image);

echo "<p>the height is $height and the width is $width </p>";
for ($i=0; $i < $width; $i++) {
for ($r=0; $r < $height; $r++) {
$rgb = imagecolorat($image, $i, $r);
echo $rgb;
echo "<br>";
}
}



which gave me something like this:

16645629
16711422
16777215
16711422
16711422
16645629
16711422
16645629
16185078
15790320
15329771
15066599
14803427
14737634
14737634
14737634
14606048
14737634
15132392
15658736
16053494
16316666
16645629
16711422

but a lot more of that.

.



Relevant Pages

  • Re: do I use fopen or fsockopen to get an image as a stream of bytes?
    ... Andy Hassall wrote: ... >>How do I get an image like that, as a stream of bytes? ... I notice that IE renders the image as an image, when I echo just the ... Prev by Date: ...
    (comp.lang.php)
  • Re: From RGB frames to stream
    ... > I have an application where I can capture single frames ... Is WME SDK able to ... > generate such stream starting from single RGB frame? ...
    (microsoft.public.windowsmedia.encoder)
  • Re: Windows media format 9 - streaming bitmap images
    ... the input profile subtype as documented so based on other ... Are you configuring an image stream or a video stream? ... RGB, have you told the write *not* to compress the images ... int nScreenWidth = GetSystemMetrics; ...
    (microsoft.public.windowsmedia.sdk)
  • Re: how to implode a URL ??
    ... Rob wrote: ... > Andy Hassall wrote: ... > Warning: file: failed to open ... > stream: Resource temporarily unavailable in ...
    (comp.lang.php)
  • YUV / RGB
    ... treat and display video stream. ... I cannot render in RGB format. ... IVMRMixerBitmap interface but if I do this on this device the result display ...
    (microsoft.public.win32.programmer.directx.graphics)