Jump to content

GD -> base64 without a temp file?


dafydd

Recommended Posts

Good Morning!

 

Context: I'm batch exporting a set of user data that includes user pictures. Of course, the recipient of the batch wants the pictures almost square, while I get & save the pictures in a 3:4 ratio.[1]

 

The issue: I'm batch exporting as XML using SimpleXML. All the data is text, except for the user pictures. I need to encode them as base64. (I tried uuencode. It uses angle brackets as coding characters. The results were ... interesting, in an XML file.) Now, if I were just encoding the picture files, well and good. But, I have to put vertical black bars on either side of my pictures to meet the ~.90 ratio requirements of the export recipient.

 

In GD, adding the bars is trivial. The hard part is going from the GD image object to a base64 encoding.

 

I can't find any way to do it that doesn't involve saving the GD image to a temp file and then encoding that file. Has anyone else run into this? An ideas how I can directly encode a GD image object?

 

Thanks!

dafydd

 

[1] - If standard digicam formats run to 3:4 (portrait orientation), why should I make my users' lives harder by forcing them to crop their pictures?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...