?
Solved

determining how a jpg was saved

Posted on 2006-04-25
13
Medium Priority
?
164 Views
Last Modified: 2010-05-01
..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
0
Comment
Question by:bczingo
  • 8
  • 5
13 Comments
 
LVL 4

Expert Comment

by:HTorres
ID: 16544887

Hi bczingo

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

that would help

0
 
LVL 3

Author Comment

by:bczingo
ID: 16577266
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
 
LVL 4

Expert Comment

by:HTorres
ID: 16582333
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 3

Author Comment

by:bczingo
ID: 16586089
Ive got 2 tests  (2 identical Jpgs - 1 saved rgb 1 saved cmyk) for you HTorres
Email me at csyst@hotmail.com
0
 
LVL 3

Author Comment

by:bczingo
ID: 16597144
HTorres
hope u got the files - any luck ?
0
 
LVL 4

Expert Comment

by:HTorres
ID: 16606665
i only got one, and i dunno if it is cmyk or rgb , can you send both?

tnx
0
 
LVL 3

Author Comment

by:bczingo
ID: 16616001
got them this time ? :)
0
 
LVL 4

Expert Comment

by:HTorres
ID: 16616181
got them,
they have very different formats
wich one is RGB ? img1 or img2?
0
 
LVL 4

Expert Comment

by:HTorres
ID: 16616373
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
 
LVL 4

Expert Comment

by:HTorres
ID: 16616391
hope this helps
0
 
LVL 4

Accepted Solution

by:
HTorres earned 1000 total points
ID: 16626622

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
 
LVL 3

Author Comment

by:bczingo
ID: 16661242
was away - just got back - looking now - thanks
0
 
LVL 4

Expert Comment

by:HTorres
ID: 16700108
C grade?

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question