Skip to content

Commit

Permalink
Added automatic CMYK to RGB conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Bianco committed Aug 16, 2010
1 parent 32d5208 commit 002b7c6
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 63 deletions.
20 changes: 19 additions & 1 deletion Image2Web.m
Expand Up @@ -42,7 +42,25 @@ int main (int argc, const char * argv[]) {
}

NSBitmapImageRep *rep = [NSBitmapImageRep imageRepWithData:[image TIFFRepresentation]];
[rep setProperty:NSImageColorSyncProfileData withValue:nil]; // remove color profile

// check if the image is cmyk; we want to convert cmyk to rgb

if([rep colorSpaceName] == NSDeviceCMYKColorSpace) {
NSBitmapImageRep *convertedRep = [rep bitmapImageRepByConvertingToColorSpace:[NSColorSpace deviceRGBColorSpace]
renderingIntent:NSColorRenderingIntentPerceptual];

if(!convertedRep) {
printf("CMYK to RGB conversion failed");
} else {
rep = convertedRep;
}
}

// remove color profile - if you save the image w/o using a save for web feature & the chosen color profile is the same as your monitor
// stripping the color profile standardize the color display

[rep setProperty:NSImageColorSyncProfileData withValue:nil];

NSData *outputImageData = [rep representationUsingType:outputType properties:nil];

switch([arguments count]) {
Expand Down
84 changes: 30 additions & 54 deletions Image2Web.xcodeproj/Mike.mode1v3
Expand Up @@ -193,32 +193,7 @@
<key>Name</key>
<string>Default</string>
<key>Notifications</key>
<array>
<dict>
<key>XCObserverAutoDisconnectKey</key>
<true/>
<key>XCObserverDefintionKey</key>
<dict>
<key>PBXStatusErrorsKey</key>
<integer>0</integer>
</dict>
<key>XCObserverFactoryKey</key>
<string>XCPerspectivesSpecificationIdentifier</string>
<key>XCObserverGUIDKey</key>
<string>XCObserverProjectIdentifier</string>
<key>XCObserverNotificationKey</key>
<string>PBXStatusBuildStateMessageNotification</string>
<key>XCObserverTargetKey</key>
<string>XCMainBuildResultsModuleGUID</string>
<key>XCObserverTriggerKey</key>
<string>awakenModuleWithObserver:</string>
<key>XCObserverValidationKey</key>
<dict>
<key>PBXStatusErrorsKey</key>
<integer>2</integer>
</dict>
</dict>
</array>
<array/>
<key>OpenEditors</key>
<array/>
<key>PerspectiveWidths</key>
Expand All @@ -234,9 +209,7 @@
<string>active-combo-popup</string>
<string>action</string>
<string>NSToolbarFlexibleSpaceItem</string>
<string>servicesModuledebug</string>
<string>debugger-enable-breakpoints</string>
<string>servicesModulebuild</string>
<string>build-and-go</string>
<string>com.apple.ide.PBXToolbarStopButton</string>
<string>get-info</string>
Expand Down Expand Up @@ -277,7 +250,7 @@
<dict>
<key>PBXSmartGroupTreeModuleColumnWidthsKey</key>
<array>
<real>194</real>
<real>186</real>
</array>
<key>PBXSmartGroupTreeModuleColumnsKey_v4</key>
<array>
Expand All @@ -303,7 +276,7 @@
</array>
</array>
<key>PBXSmartGroupTreeModuleOutlineStateVisibleRectKey</key>
<string>{{0, 0}, {194, 697}}</string>
<string>{{0, 0}, {186, 695}}</string>
</dict>
<key>PBXTopSmartGroupGIDs</key>
<array/>
Expand All @@ -315,19 +288,19 @@
<key>GeometryConfiguration</key>
<dict>
<key>Frame</key>
<string>{{0, 0}, {211, 715}}</string>
<string>{{0, 0}, {203, 713}}</string>
<key>GroupTreeTableConfiguration</key>
<array>
<string>MainColumn</string>
<real>194</real>
<real>186</real>
</array>
<key>RubberWindowFrame</key>
<string>0 302 1440 756 0 0 1920 1058 </string>
<string>0 124 1440 754 0 0 1440 878 </string>
</dict>
<key>Module</key>
<string>PBXSmartGroupTreeModule</string>
<key>Proportion</key>
<string>211pt</string>
<string>203pt</string>
</dict>
<dict>
<key>Dock</key>
Expand All @@ -352,10 +325,11 @@
<key>_historyCapacity</key>
<integer>0</integer>
<key>bookmark</key>
<string>275B3C4E11B9E50000B57E8F</string>
<string>279FF11D1219B9D000E0AA09</string>
<key>history</key>
<array>
<string>275B3C3F11B9E2E400B57E8F</string>
<string>279FF1181219B86C00E0AA09</string>
<string>279FF1191219B86C00E0AA09</string>
</array>
</dict>
<key>SplitCount</key>
Expand All @@ -367,14 +341,14 @@
<key>GeometryConfiguration</key>
<dict>
<key>Frame</key>
<string>{{0, 0}, {1224, 485}}</string>
<string>{{0, 0}, {1232, 483}}</string>
<key>RubberWindowFrame</key>
<string>0 302 1440 756 0 0 1920 1058 </string>
<string>0 124 1440 754 0 0 1440 878 </string>
</dict>
<key>Module</key>
<string>PBXNavigatorGroup</string>
<key>Proportion</key>
<string>485pt</string>
<string>483pt</string>
</dict>
<dict>
<key>ContentConfiguration</key>
Expand All @@ -387,9 +361,9 @@
<key>GeometryConfiguration</key>
<dict>
<key>Frame</key>
<string>{{0, 490}, {1224, 225}}</string>
<string>{{0, 488}, {1232, 225}}</string>
<key>RubberWindowFrame</key>
<string>0 302 1440 756 0 0 1920 1058 </string>
<string>0 124 1440 754 0 0 1440 878 </string>
</dict>
<key>Module</key>
<string>XCDetailModule</string>
Expand All @@ -398,7 +372,7 @@
</dict>
</array>
<key>Proportion</key>
<string>1224pt</string>
<string>1232pt</string>
</dict>
</array>
<key>Name</key>
Expand All @@ -413,9 +387,9 @@
</array>
<key>TableOfContents</key>
<array>
<string>275B3C4F11B9E50000B57E8F</string>
<string>279FF10F1219B6E400E0AA09</string>
<string>1CE0B1FE06471DED0097A5F4</string>
<string>275B3C5011B9E50000B57E8F</string>
<string>279FF1101219B6E400E0AA09</string>
<string>1CE0B20306471E060097A5F4</string>
<string>1CE0B20506471E060097A5F4</string>
</array>
Expand Down Expand Up @@ -534,7 +508,7 @@
<key>StatusbarIsVisible</key>
<true/>
<key>TimeStamp</key>
<real>297395456.19411403</real>
<real>0.0</real>
<key>ToolbarDisplayMode</key>
<integer>1</integer>
<key>ToolbarIsVisible</key>
Expand All @@ -549,11 +523,11 @@
<integer>5</integer>
<key>WindowOrderList</key>
<array>
<string>275B3C4211B9E2E400B57E8F</string>
<string>279FF1061219B6AC00E0AA09</string>
<string>/Users/Mike/Work/CocoaApps/Image2Web/Image2Web.xcodeproj</string>
</array>
<key>WindowString</key>
<string>0 302 1440 756 0 0 1920 1058 </string>
<string>0 124 1440 754 0 0 1440 878 </string>
<key>WindowToolsV3</key>
<array>
<dict>
Expand Down Expand Up @@ -583,14 +557,16 @@
<key>Frame</key>
<string>{{0, 0}, {964, 370}}</string>
<key>RubberWindowFrame</key>
<string>578 372 964 686 0 0 1920 1058 </string>
<string>288 192 964 686 0 0 1440 878 </string>
</dict>
<key>Module</key>
<string>PBXNavigatorGroup</string>
<key>Proportion</key>
<string>370pt</string>
</dict>
<dict>
<key>BecomeActive</key>
<true/>
<key>ContentConfiguration</key>
<dict>
<key>PBXProjectModuleGUID</key>
Expand All @@ -600,14 +576,14 @@
<key>XCBuildResultsTrigger_Collapse</key>
<integer>1021</integer>
<key>XCBuildResultsTrigger_Open</key>
<integer>1012</integer>
<integer>1011</integer>
</dict>
<key>GeometryConfiguration</key>
<dict>
<key>Frame</key>
<string>{{0, 375}, {964, 270}}</string>
<key>RubberWindowFrame</key>
<string>578 372 964 686 0 0 1920 1058 </string>
<string>288 192 964 686 0 0 1440 878 </string>
</dict>
<key>Module</key>
<string>PBXBuildResultsModule</string>
Expand All @@ -629,17 +605,17 @@
<true/>
<key>TableOfContents</key>
<array>
<string>275B3C4211B9E2E400B57E8F</string>
<string>275B3C5111B9E50000B57E8F</string>
<string>279FF1061219B6AC00E0AA09</string>
<string>279FF1111219B6E400E0AA09</string>
<string>1CD0528F0623707200166675</string>
<string>XCMainBuildResultsModuleGUID</string>
</array>
<key>ToolbarConfiguration</key>
<string>xcode.toolbar.config.buildV3</string>
<key>WindowString</key>
<string>578 372 964 686 0 0 1920 1058 </string>
<string>288 192 964 686 0 0 1440 878 </string>
<key>WindowToolGUID</key>
<string>275B3C4211B9E2E400B57E8F</string>
<string>279FF1061219B6AC00E0AA09</string>
<key>WindowToolIsVisible</key>
<false/>
</dict>
Expand Down
62 changes: 54 additions & 8 deletions Image2Web.xcodeproj/Mike.pbxuser
Expand Up @@ -3,6 +3,7 @@
08FB7793FE84155DC02AAC07 /* Project object */ = {
activeBuildConfigurationName = Release;
activeExecutable = 279AAAA00DD4C62600EF8D6C /* Image2Web */;
activeSDKPreference = macosx10.6;
activeTarget = 8DD76F960486AA7600D96B5E /* Image2Web */;
addToTargets = (
8DD76F960486AA7600D96B5E /* Image2Web */,
Expand Down Expand Up @@ -53,7 +54,7 @@
PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID;
PBXFileTableDataSourceColumnWidthsKey = (
20,
945,
953,
60,
20,
48,
Expand All @@ -70,22 +71,26 @@
PBXFileDataSource_Warnings_ColumnID,
);
};
PBXPerProjectTemplateStateSaveDate = 297395444;
PBXWorkspaceStateSaveDate = 297395444;
PBXPerProjectTemplateStateSaveDate = 303675107;
PBXWorkspaceStateSaveDate = 303675107;
};
perUserProjectItems = {
275B3C3F11B9E2E400B57E8F /* PBXTextBookmark */ = 275B3C3F11B9E2E400B57E8F /* PBXTextBookmark */;
275B3C4E11B9E50000B57E8F /* PBXTextBookmark */ = 275B3C4E11B9E50000B57E8F /* PBXTextBookmark */;
275B3C3F11B9E2E400B57E8F = 275B3C3F11B9E2E400B57E8F /* PBXTextBookmark */;
275B3C4E11B9E50000B57E8F = 275B3C4E11B9E50000B57E8F /* PBXTextBookmark */;
279FF1181219B86C00E0AA09 /* PBXTextBookmark */ = 279FF1181219B86C00E0AA09 /* PBXTextBookmark */;
279FF1191219B86C00E0AA09 /* PBXBookmark */ = 279FF1191219B86C00E0AA09 /* PBXBookmark */;
279FF11A1219B86C00E0AA09 /* PBXTextBookmark */ = 279FF11A1219B86C00E0AA09 /* PBXTextBookmark */;
279FF11D1219B9D000E0AA09 /* PBXTextBookmark */ = 279FF11D1219B9D000E0AA09 /* PBXTextBookmark */;
};
sourceControlManager = 279AAAA90DD4C62B00EF8D6C /* Source Control */;
userBuildSettings = {
};
};
08FB7796FE84155DC02AAC07 /* Image2Web.m */ = {
uiCtxt = {
sepNavIntBoundsRect = "{{0, 0}, {1163, 1022}}";
sepNavSelRange = "{239, 0}";
sepNavVisRange = "{0, 737}";
sepNavIntBoundsRect = "{{0, 0}, {1171, 1157}}";
sepNavSelRange = "{1378, 0}";
sepNavVisRange = "{985, 1181}";
sepNavVisRect = "{{0, 0}, {1185, 467}}";
};
};
Expand Down Expand Up @@ -168,6 +173,47 @@
isa = PBXCodeSenseManager;
indexTemplatePath = "";
};
279FF1181219B86C00E0AA09 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 32A70AAB03705E1F00C91783 /* Image2Web_Prefix.pch */;
name = "Image2Web_Prefix.pch: 1";
rLen = 0;
rLoc = 0;
rType = 0;
vrLen = 160;
vrLoc = 0;
};
279FF1191219B86C00E0AA09 /* PBXBookmark */ = {
isa = PBXBookmark;
fRef = 08FB7796FE84155DC02AAC07 /* Image2Web.m */;
};
279FF11A1219B86C00E0AA09 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 08FB7796FE84155DC02AAC07 /* Image2Web.m */;
name = "Image2Web.m: 61";
rLen = 0;
rLoc = 1692;
rType = 0;
vrLen = 1181;
vrLoc = 985;
};
279FF11D1219B9D000E0AA09 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 08FB7796FE84155DC02AAC07 /* Image2Web.m */;
name = "Image2Web.m: 50";
rLen = 0;
rLoc = 1378;
rType = 0;
vrLen = 1181;
vrLoc = 985;
};
32A70AAB03705E1F00C91783 /* Image2Web_Prefix.pch */ = {
uiCtxt = {
sepNavIntBoundsRect = "{{0, 0}, {1171, 453}}";
sepNavSelRange = "{0, 0}";
sepNavVisRange = "{0, 160}";
};
};
8DD76F960486AA7600D96B5E /* Image2Web */ = {
activeExec = 0;
executables = (
Expand Down

0 comments on commit 002b7c6

Please sign in to comment.