Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retrieving data #1

Closed
gmcusaro opened this issue Feb 3, 2021 · 9 comments · Fixed by #2
Closed

Retrieving data #1

gmcusaro opened this issue Feb 3, 2021 · 9 comments · Fixed by #2

Comments

@gmcusaro
Copy link
Contributor

gmcusaro commented Feb 3, 2021

How is it possible with this code in READ.me to recover name, version, profile type, copyright, etc ...?

for tag in file.tags {
  print(tag) 
}

Something like that is possible?

icm

@hughbe
Copy link
Owner

hughbe commented Feb 3, 2021

Have you seen the code sample in the readme?

let file = try ICCColorProfile(data: data)
for tag in file.tags {
    print(tag)
}

What you can do to create an interface like the above is switch on tag and do different things based on the tag.

Would it be useful for you to get the textual signature of the tag or data type for each tag?

@gmcusaro
Copy link
Contributor Author

gmcusaro commented Feb 3, 2021

I saw your code, you did a great job following the pdf specs.
I am attaching the console output for sRGB.icc for example.
Not necessarily a window, but if you want to add something similar in SwiftUI it would be very useful.
A code example to get more readable tags like: profile name, version, colorSpace, intent, copyright, acsp signature, etc...

Something like that:

version: '2.0',
intent: 'Perceptual',
deviceClass: 'Monitor',
colorSpace: 'RGB',
connectionSpace: 'XYZ',
description: 'sRGB IEC61966-2-1',
deviceModelDescription: 'IEC 61966-2-1 Default RGB Colour Space - sRGB',
viewingConditionsDescription: 'Reference Viewing Condition in IEC 61966-2-1',
copyright: 'Copyright International Color Consortium'

sRGB.md.zip

@gmcusaro
Copy link
Contributor Author

gmcusaro commented Feb 8, 2021

Going deeper than the example code in description, how to get TagTypeSignature enum cases?

            let myData = try Data(contentsOf: url)
            let profile = try ICCColorProfile(data: myData)
            for tag in profile.tags {
                switch tag {
                    case .profileDescription(.textDescription(let signature)): print(signature.sig)
                    default: break
                }
            }

@hughbe
Copy link
Owner

hughbe commented Feb 8, 2021

I think I’m going to have to make some breaking changes and have something like

struct ICCRecord
{
public let signature: String
public let dataType: String
public let data: ICCRecordData
}

where data is a enum of different types

@gmcusaro
Copy link
Contributor Author

gmcusaro commented Feb 8, 2021

With signature I refer to an enum

public struct textDescriptionType {
    public let sig: TagTypeSignature // <-- this enum
...

Is possible and how retrieve the data of public enum TagTypeSignature: String?

public enum TagTypeSignature: String {
    /// [ICC.1:2010] 10.2 chromaticityType
    case chromacityType = "chrm"
    
    /// [ICC.1:2010] 10.3 colorantOrderType
    case colorantOrderType = "clro"
    
    /// [ICC.1:2010] 10.4 colorantTableType
    case colorantTableType = "clrt"

    /// [ICC.1:2001-04] 6.5.15 screeningType
    case screeningType = "scrn"
...

@hughbe
Copy link
Owner

hughbe commented Feb 8, 2021

See #2

I'm not going to create a UI to display things, as it should be trivial to do that in your own SwiftUI component once that PR is merged in (please review and let me know so I can submit:) )

If you do create the component and want to send it in as a PR I may consider it

@gmcusaro
Copy link
Contributor Author

gmcusaro commented Feb 8, 2021

This refactoring makes everything much more practical. Grate job! I agree with you, the interface becomes a trivial thing with these changes. Everything looks ok, for merging the PR!
In the new sample code print (tag.Signature), signature has a lowercase s.

@gmcusaro gmcusaro closed this as completed Feb 8, 2021
@hughbe
Copy link
Owner

hughbe commented Feb 9, 2021

Well noticed, find replace is annoying in xcode :( Fixed

@hughbe
Copy link
Owner

hughbe commented Feb 9, 2021

Also released 1.1.0 - update!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants