More Fun With MySQL and Images

Victor Subervi victorsubervi at gmail.com
Thu Apr 17 18:15:19 CEST 2008


Yeah, I figured that out between posts ;)

On Thu, Apr 17, 2008 at 10:39 AM, J. Cliff Dyer <jcd at unc.edu> wrote:

> On Thu, 2008-04-17 at 09:52 -0500, Victor Subervi wrote:
> > Never mind. Apparently, these tags throw it for that loop:
> >   print '<html><body>\n'
> > I´m surprised they would, but gratified I found the problem.
> > Victor
> >
> >
>
> Why does that surprise you?  A jpeg has a well-defined header that tells
> whatever application is rendering it what to look for.  By putting those
> tags at the beginning of the data sent to your browser, you're no longer
> getting a well-formed jpeg.  The header is wrong.
>
> As an experiment, if you're on *nix, or have access to a decent shell,
> try this:
>
> $ echo '<html><body>' > newfile.jpg
> $ cat /path/to/any_normal_jpeg >> newfile.jpg
> $ echo '</body></html>' >> newfile.jpg
>
> If you don't have access to a shell, open a JPEG with your favorite text
> editor, and manually add "<html><body>" to the beginning, and save it
> out.
>
> Then try to open newfile in any piece of software of your choosing.
> It's no longer a well-formed jpeg, so it won't work.  That's exactly
> what you're asking the browser to do.
>
> I guess this isn't really python related, so my apologies for that.
>
> Cheers,
> Cliff
>
>
>
>
> --
> Oook,
> J. Cliff Dyer
> Carolina Digital Library and Archives
> UNC Chapel Hill
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080417/cb3686b8/attachment.html>


More information about the Python-list mailing list