determining how a jpg was saved

..I asked this queston before with no one responding - still need an answer

I have an app that accepts .jpgs to install as a background on HTML pages - What I need is a way of determining if the jpeg was saved as RGB (good) or CMYK (bad - won't show on browser)
Any one know of any VB6 code to do this - Bonus would be code to convert from CMYK to RGB but this is not my primary need.
Experts-
Thanks in advance
LVL 3
bczingoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

HTorresCommented:

Hi bczingo

do you have a link for rgb and cmyk jpg's?

that would help

0
bczingoAuthor Commented:
HTorres
Dont quite know what you mean - The jpgs are from many sources and change frequently - The web page is rendered on the fly and I need to double check that a jpg will show before I link to it . (its a local (same drive) link so I can examine the file before using it- I just need to know what to look for.
0
HTorresCommented:
Hi BC
I mean if you have some rgb jpg file and some cmyk jpg file so i can make something for you to get what you want

that would help
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

bczingoAuthor Commented:
Ive got 2 tests  (2 identical Jpgs - 1 saved rgb 1 saved cmyk) for you HTorres
Email me at csyst@hotmail.com
0
bczingoAuthor Commented:
HTorres
hope u got the files - any luck ?
0
HTorresCommented:
i only got one, and i dunno if it is cmyk or rgb , can you send both?

tnx
0
bczingoAuthor Commented:
got them this time ? :)
0
HTorresCommented:
got them,
they have very different formats
wich one is RGB ? img1 or img2?
0
HTorresCommented:
Private Sub Command1_Click()

    DetermineRGBorCYMK ("C:\windows\desktop\img1.jpg")
   
End Sub

Sub DetermineRGBorCYMK(f As String)

    Dim ff As String
    Dim strbuffer As String
   
    If Dir(f) = "" Then
        MsgBox "File does not exist", vbInformation, ""
    Else
       
        Open f For Binary As #1
        strbuffer = Space$(20)
        Get #1, 1, strbuffer
        Close
       
        ff = "UNKNOWN"
        If Mid(strbuffer, 7, 4) = "JFIF" Then ff = "RGB"
        If Mid(strbuffer, 7, 4) = "Exif" Then ff = "CMYK"
       
        MsgBox f & " format is " & ff
    End If
   
End Sub

thats it.

i also saw that both files were made by adobe Adobe Photoshop CS Windows, so, making them rgb think would be easy.

this can easily be changed for multiple files

sub batch()
    dim a as long
    me.drive1.drive="C:"
    me.dir1.path="c:\folder"
    me.file1.path="C:\folder"
   
    for a = 0 to me.file1.listcount
        DetermineRGBorCYMK(me.file1.path & "\" & me.file1.list(a))
    next
end sub

Sub DetermineRGBorCYMK(f As String,moveCMYK as boolean)

    Dim ff As String
    Dim strbuffer As String
   
    If Dir(f) = "" Then
        MsgBox "File does not exist", vbInformation, ""
    Else
       
        Open f For Binary As #1
        strbuffer = Space$(20)
        Get #1, 1, strbuffer
        Close
       
        ff = "UNKNOWN"
        If Mid(strbuffer, 7, 4) = "JFIF" Then ff = "RGB"
        If Mid(strbuffer, 7, 4) = "Exif" Then ff = "CMYK"
       
        'MsgBox f & " format is " & ff
        if moveCMYK and ff = "CMYK" then
           if dir("c:\folder\CMYK",vbdirectory)="" then
              mkdir "c:\folder\CMYK"
           end if
           name f as "c:\folder\cmyk\" & justfilename(f)
    End If
   
End Sub

function justfilename( f as string) as string
    dim a as long
    dim r as string
    a = len(f)
    do
         a = a -1
         if a =0 then
            r=f
            exit do
         end if
         if mid(f,a,1)="\" then              
            r = mid(f,a+1,len(f)) ':)
            exit do
         end if
    loop
    justfilename=r
end function
0
HTorresCommented:
hope this helps
0
HTorresCommented:

sub batch()
    dim a as long
    me.drive1.drive="C:"
    me.dir1.path="c:\folder"
    me.file1.path="C:\folder"
   
    for a = 0 to me.file1.listcount
        DetermineRGBorCYMK me.file1.path & "\" & me.file1.list(a), TRUE
    next
end sub

:) sometimes it happens,... ...
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bczingoAuthor Commented:
was away - just got back - looking now - thanks
0
HTorresCommented:
C grade?

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.