Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
|
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 18th, 2006, 10:20 AM
Authorized User
 
Join Date: Mar 2004
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default PNG image in base64 encoding

Hello!

Could anyone tell me, please, where can I read about how the data is organized in a PNG image in base64 (or is it HEX or something yet else) format?

I don't need anything very advanced, simply to understand how I could generate, for example, a simple image with PHP.

I found PNG specification (http://www.w3.org/TR/PNG/), but I couldn't really find what I was looking for (I hope that I don't need to learn all that before I can understand the basics of how this works...).

I have a (part of) sample code like this (which needs to be base64 encoded and then when output generate a PNG image):
Code:
wD//////////////1QAAAAAAAAAAAAAAAAAACjo////////////////
AP////////////+MAAAAAAAAAAAAAAAAAAAAADj////////////////
8A////////////9BAAAAAAAAAAAAAAAAAAAAAAALD//////////////
And wanted to know (at first) what all those characters mean. What is "AP", "8A", "wD"? What do "/"'s (and "1", "Q", "A" etc.) represent.

Can someone, please, explain this or show where I can read about it?

Thanks!

 
Old April 20th, 2006, 01:58 PM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

Er, are you trying to decode base 64?
http://www.php.net/base64_decode

Regards,
Rich

--
Author,
Beginning CSS: Cascading Style Sheets For Web Design
CSS Instant Results

http://www.catb.org/~esr/faqs/smart-questions.html
 
Old April 20th, 2006, 02:12 PM
Authorized User
 
Join Date: Mar 2004
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you for the reply!

Well, I would like to know how PNG image is generated so I could change it. I know the code, for example, which would generate a black '2' (see below), but I want it to appear differently, in a different shape, colours etc.

I just said that base64 is used to generate the image. I'm not sure how it is done and why it is done, I just know that there is this code (I don't know what format it is) which if I encode in base64 and output as png image, a browser will display as an image.

2:
Code:
AP/////////////////////////////////////////////////////
8A/////////////////////////////////////////////////////
wD/////////////////////////////////////////////////////
AP/////////////////okFAkCAAABCBIfNT////////////////////
8A///////////////8hAgAAAAAAAAAAAAAAFTo/////////////////
wD//////////////1QAAAAAAAAAAAAAAAAAACjo////////////////
AP////////////+MAAAAAAAAAAAAAAAAAAAAADj////////////////
8A////////////9BAAAAAAAAAAAAAAAAAAAAAAALD//////////////
wD///////////+gAAAAAAAAAHjs+KwMAAAAAAAAVP//////////////
AP///////////1gAAAAAAABM/////6QAAAAAAAAU///////////////
8A////////////KAAAAAAAALj/////+AAAAAAAAAD//////////////
wD///////////+MfGBMOCAI8P/////wAAAAAAAACP//////////////
AP///////////////////////////5wAAAAAAAAw///////////////
8A///////////////////////////oFAAAAAAAAHz//////////////
wD/////////////////////////6CgAAAAAAAAE3P//////////////
AP///////////////////////9ggAAAAAAAAAHT////////////////
8A//////////////////////+0DAAAAAAAAAA8+P///////////////
wD/////////////////////gAAAAAAAAAAAKOj/////////////////
AP//////////////////9FAAAAAAAAAAADzw///////////////////
8A/////////////////+g4AAAAAAAAAABk/P///////////////////
wD////////////////oKAAAAAAAAAAMqP//////////////////////
AP//////////////6CgAAAAAAAAAMNz////////////////////////
8A//////////////g4AAAAAAAAAFT0/////////////////////////
wD/////////////bAAAAAAAAABU/P//////////////////////////
AP///////////8wAAAAAAAAAAAAAAAAAAAAAAAAA///////////////
8A////////////SAAAAAAAAAAAAAAAAAAAAAAAAAD//////////////
wD//////////9wAAAAAAAAAAAAAAAAAAAAAAAAAAP//////////////
AP//////////hAAAAAAAAAAAAAAAAAAAAAAAAAAA///////////////
8A//////////9AAAAAAAAAAAAAAAAAAAAAAAAAAAD//////////////
wD//////////xAAAAAAAAAAAAAAAAAAAAAAAAAAAP//////////////
AP////////////////////////////////////////////////////8=
 
Old April 20th, 2006, 02:21 PM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

I'm not following along. PHP's image manipulation functions are found in the GD library, and would be the tools you would use to generate a PNG image.

http://www.php.net/image

Regards,
Rich

--
Author,
Beginning CSS: Cascading Style Sheets For Web Design
CSS Instant Results

http://www.catb.org/~esr/faqs/smart-questions.html
 
Old April 20th, 2006, 02:30 PM
Authorized User
 
Join Date: Mar 2004
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well, this is a way to generate PNG images not using GD library (which I'm not familiar with too).

It is used by phpBB2 image verification and I just wanted to understand how it works so I could adjust it to my needs.

Thanks!






Similar Threads
Thread Thread Starter Forum Replies Last Post
creating html from png Alper HTML Code Clinic 2 November 2nd, 2007 10:02 PM
How to Encode image to base64? OniShirox Javascript How-To 4 July 5th, 2007 03:10 AM
Decoding Base64 Encoded Data and saving the image mookashi XML 14 August 3rd, 2006 05:52 PM
Image Upload to base64 format laker66 ASP.NET 1.0 and 1.1 Basics 1 April 8th, 2004 12:35 AM
PNG Transparency in IE richard.york Javascript 4 January 19th, 2004 08:26 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.