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

Well, I'm groping in the dark here, but I think that
imagecreatefromstring would give me an actual image, whereas what I
want is an actual string, and I don't know how to get a string from an
image file.

The thing with Postscript is that it is a plain text file. And to
represent an image in Postscript, I think that image needs to be
represented as a plain text listing of all its bytes.

I'm currently working at a manufacturing company that would like to
capture images (of a product) off of its website everytime it makes a
sale on the website, and then have that image and some text combined
into a Postscript file that prints out in the shipping department. The
image is suppose to help people see what product needs to be shipped.

I just wrote this code:


<?php

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

$string = <<<EOF
%!
% Sample of printing text

/Times-Roman findfont % Get the basic font
20 scalefont % Scale the font to 20 points
setfont % Make it the current font

newpath % Start a new path
72 72 moveto % Lower left corner of text at (72, 72)
(14k White Gold 2 mm Classic Engagement Ring with Heart Shaped Side
Stones .80 ct. tw.) show % Typeset "Hello, world!"

100 200 translate
26 34 scale
26 34 8 [26 0 0 -34 0 34]
{<
$image
>}
image

showpage

EOF;

echo $string;
?>


Then I went to look at it in my browser. The image bytes show up as a
mess. It doesn't matter what character encoding I choose, it still
looks like a mess. IE asks me to download the file, which I do, and
then I open it in my text editor, and it still looks like a mess, with
strange Russian letters showing up.

The thing is, it doesn't look like plain text. Somehow I was expecting
a lot of 00089000. That kind of stuff. Not foreign letters.

So I'm left thinking that I'm not getting the raw bytes, or they are
getting interpreted somehow, along the way, whereas what I need is the
raw description of that image, because that is what Postscript needs.

.



Relevant Pages

  • Re: Pagesizes, Orientation, Bounding Boxes and multiple pages
    ... which accepts raw print output which I'm now merging so that it ... creates a PS file with the raw output projected onto the digitised ... PostScript is a programming language, ... render it at the same place if the document runs to a second page as: ...
    (comp.lang.postscript)
  • Re: [opensuse] Is there a printing expert in the house?
    ... What you are seen above is postscript, ... All linux printing is done as postscript ... When you print a plain text file it is typically converted to postscript first, then it is sent to the print server. ...
    (SuSE)
  • Re: LPD and text-based printer
    ... Is it possible to create an LPD printer that outputs to a text file? ... postscript and run through ghostscript? ... any smarts to prevent me from sending postscript/pdf to the raw printer. ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
    (Debian-User)
  • Re: [opensuse] Is there a printing expert in the house?
    ... The problem appeared while I was still using a print server that has ... encoded using PostScript Level 3. ... The only copy of Acroreader on the machine is v8. ... When you print a plain text file it is typically converted to ...
    (SuSE)
  • Re: [SLE] CUPS configuration
    ... > I have what might be a strange configuration for a CUPS server. ... > I can print using JetDirect, but the postscript font rendering is not as ... > conversion and CUPS does the postscript conversion for the printer. ... Try seting up another cups to the printer as a raw printer. ...
    (SuSE)