Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.
Hi all, please see this major site announcement: https://www.boards.ie/discussion/2058427594/boards-ie-2026

Determine image type from Base64 string

  • 27-03-2008 01:18PM
    #1
    Registered Users, Registered Users 2 Posts: 2,929 ✭✭✭


    Hi

    I have an XML file that will contain images in Base64 encoded format. I am currently able to reconstruct them as images fine, but i am only testing with JPGs at the moment. Further down the road there will be different types such as PNG and GIF

    Is there a way to asses what type of image from the string as in is there a control set that tells you what it is?

    What I am doing is converting InfoPath 2007 forms to XHTML using the XML and XSL file contained within the XSN file. The XML file contains the image encoded as a Base64 string

    Ta


Comments

  • Closed Accounts Posts: 1,567 ✭✭✭Martyr


    could you decode a few bytes of the base64 encoded image and check the header for PNG/JPEG or GIF ???

    the first few bytes are usually header.


  • Registered Users, Registered Users 2 Posts: 2,929 ✭✭✭Ginger


    Its loaded into a byte array before writing so I am sure I can..

    I am looking to see if its possible before investing some time into it


  • Registered Users, Registered Users 2, Paid Member Posts: 2,427 ✭✭✭ressem


    The info here might help to recognise what you're looking for.

    http://www.mikekunz.com/image_file_header.html


  • Registered Users, Registered Users 2 Posts: 2,929 ✭✭✭Ginger


    I will have a whack at it and see what happens


  • Registered Users, Registered Users 2 Posts: 2,929 ✭✭✭Ginger


    ressem .. thanks for that infomation.. does exactly what I want..

    Again thanks muchly


  • Advertisement
Advertisement
Advertisement