summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lcms2mt/utils/jpgicc/jpgicc.c')
-rw-r--r--lcms2mt/utils/jpgicc/jpgicc.c133
1 files changed, 63 insertions, 70 deletions
diff --git a/lcms2mt/utils/jpgicc/jpgicc.c b/lcms2mt/utils/jpgicc/jpgicc.c
index 41deff08..00ac7aea 100644
--- a/lcms2mt/utils/jpgicc/jpgicc.c
+++ b/lcms2mt/utils/jpgicc/jpgicc.c
@@ -866,8 +866,8 @@ int DoTransform(cmsContext ContextID, cmsHTRANSFORM hXForm, int OutputColorSpace
if (EmbedProfile && cOutProf)
DoEmbedProfile(cOutProf);
- ScanLineIn = (JSAMPROW) malloc(Decompressor.output_width * Decompressor.num_components);
- ScanLineOut = (JSAMPROW) malloc(Compressor.image_width * Compressor.num_components);
+ ScanLineIn = (JSAMPROW) malloc((size_t) Decompressor.output_width * Decompressor.num_components);
+ ScanLineOut = (JSAMPROW) malloc((size_t) Compressor.image_width * Compressor.num_components);
while (Decompressor.output_scanline <
Decompressor.output_height) {
@@ -1028,97 +1028,89 @@ int TransformImage(cmsContext ContextID, char *cDefInpProf, char *cOutputProf)
}
-// Simply print help
-
static
-void Help(int level)
+void Help(cmsContext ContextID, int level)
{
- fprintf(stderr, "little cms ICC profile applier for JPEG - v3.2 [LittleCMS %2.2f]\n\n", LCMS_VERSION / 1000.0);
-
- switch(level) {
-
- default:
- case 0:
- fprintf(stderr, "usage: jpgicc [flags] input.jpg output.jpg\n");
+ UTILS_UNUSED_PARAMETER(level);
- fprintf(stderr, "\nflags:\n\n");
- fprintf(stderr, "%cv - Verbose\n", SW);
- fprintf(stderr, "%ci<profile> - Input profile (defaults to sRGB)\n", SW);
- fprintf(stderr, "%co<profile> - Output profile (defaults to sRGB)\n", SW);
+ fprintf(stderr, "usage: jpgicc [flags] input.jpg output.jpg\n");
- PrintRenderingIntents(NULL);
+ fprintf(stderr, "\nflags:\n\n");
+ fprintf(stderr, "-v - Verbose\n");
+ fprintf(stderr, "-i<profile> - Input profile (defaults to sRGB)\n");
+ fprintf(stderr, "-o<profile> - Output profile (defaults to sRGB)\n");
+ PrintBuiltins();
- fprintf(stderr, "%cb - Black point compensation\n", SW);
- fprintf(stderr, "%cd<0..1> - Observer adaptation state (abs.col. only)\n", SW);
- fprintf(stderr, "%cn - Ignore embedded profile\n", SW);
- fprintf(stderr, "%ce - Embed destination profile\n", SW);
- fprintf(stderr, "%cs<new profile> - Save embedded profile as <new profile>\n", SW);
+ PrintRenderingIntents(ContextID);
- fprintf(stderr, "\n");
- fprintf(stderr, "%cc<0,1,2,3> - Precalculates transform (0=Off, 1=Normal, 2=Hi-res, 3=LoRes) [defaults to 1]\n", SW);
- fprintf(stderr, "\n");
+ fprintf(stderr, "-b - Black point compensation\n");
+ fprintf(stderr, "-d<0..1> - Observer adaptation state (abs.col. only)\n");
+ fprintf(stderr, "-n - Ignore embedded profile\n");
+ fprintf(stderr, "-e - Embed destination profile\n");
+ fprintf(stderr, "-s<new profile> - Save embedded profile as <new profile>\n");
- fprintf(stderr, "%cp<profile> - Soft proof profile\n", SW);
- fprintf(stderr, "%cm<0,1,2,3> - SoftProof intent\n", SW);
- fprintf(stderr, "%cg - Marks out-of-gamut colors on softproof\n", SW);
- fprintf(stderr, "%c!<r>,<g>,<b> - Out-of-gamut marker channel values\n", SW);
+ fprintf(stderr, "\n");
- fprintf(stderr, "\n");
- fprintf(stderr, "%cq<0..100> - Output JPEG quality\n", SW);
+ fprintf(stderr, "-c<0,1,2,3> - Precalculates transform (0=Off, 1=Normal, 2=Hi-res, 3=LoRes) [defaults to 1]\n");
+ fprintf(stderr, "\n");
- fprintf(stderr, "\n");
- fprintf(stderr, "%ch<0,1,2,3> - More help\n", SW);
- break;
+ fprintf(stderr, "-p<profile> - Soft proof profile\n");
+ fprintf(stderr, "-m<0,1,2,3> - SoftProof intent\n");
+ fprintf(stderr, "-g - Marks out-of-gamut colors on softproof\n");
+ fprintf(stderr, "-!<r>,<g>,<b> - Out-of-gamut marker channel values\n");
- case 1:
+ fprintf(stderr, "\n");
+ fprintf(stderr, "-q<0..100> - Output JPEG quality\n");
- fprintf(stderr, "Examples:\n\n"
- "To color correct from scanner to sRGB:\n"
- "\tjpgicc %ciscanner.icm in.jpg out.jpg\n"
- "To convert from monitor1 to monitor2:\n"
- "\tjpgicc %cimon1.icm %comon2.icm in.jpg out.jpg\n"
- "To make a CMYK separation:\n"
- "\tjpgicc %coprinter.icm inrgb.jpg outcmyk.jpg\n"
- "To recover sRGB from a CMYK separation:\n"
- "\tjpgicc %ciprinter.icm incmyk.jpg outrgb.jpg\n"
- "To convert from CIELab ITU/Fax JPEG to sRGB\n"
- "\tjpgicc in.jpg out.jpg\n\n",
- SW, SW, SW, SW, SW);
- break;
+ fprintf(stderr, "Examples:\n\n"
+ "To color correct from scanner to sRGB:\n"
+ "\tjpgicc -iscanner.icm in.jpg out.jpg\n"
+ "To convert from monitor1 to monitor2:\n"
+ "\tjpgicc -imon1.icm -omon2.icm in.jpg out.jpg\n"
+ "To make a CMYK separation:\n"
+ "\tjpgicc -oprinter.icm inrgb.jpg outcmyk.jpg\n"
+ "To recover sRGB from a CMYK separation:\n"
+ "\tjpgicc -iprinter.icm incmyk.jpg outrgb.jpg\n"
+ "To convert from CIELab ITU/Fax JPEG to sRGB\n"
+ "\tjpgicc in.jpg out.jpg\n\n");
- case 2:
- PrintBuiltins();
- break;
- case 3:
+ fprintf(stderr, "This program is intended to be a demo of the Little CMS\n"
+ "color engine. Both lcms and this program are open source.\n"
+ "You can obtain both in source code at https://www.littlecms.com\n"
+ "For suggestions, comments, bug reports etc. send mail to\n"
+ "info@littlecms.com\n\n");
- fprintf(stderr, "This program is intended to be a demo of the little cms\n"
- "engine. Both lcms and this program are freeware. You can\n"
- "obtain both in source code at http://www.littlecms.com\n"
- "For suggestions, comments, bug reports etc. send mail to\n"
- "marti@littlecms.com\n\n");
- break;
- }
-
- exit(0);
+ exit(0);
}
// The toggles stuff
static
-void HandleSwitches(int argc, char *argv[])
+void HandleSwitches(cmsContext ContextID, int argc, char *argv[])
{
int s;
- while ((s=xgetopt(argc,argv,"bBnNvVGgh:H:i:I:o:O:P:p:t:T:c:C:Q:q:M:m:L:l:eEs:S:!:D:d:")) != EOF) {
+ while ((s=xgetopt(argc,argv,"bBnNvVGgh:H:i:I:o:O:P:p:t:T:c:C:Q:q:M:m:L:l:eEs:S:!:D:d:-:")) != EOF) {
switch (s)
{
+ case '-':
+ if (strcmp(xoptarg, "help") == 0)
+ {
+ Help(ContextID, 0);
+ }
+ else
+ {
+ FatalError("Unknown option - run without args to see valid ones.\n");
+ }
+ break;
+
case 'b':
case 'B':
BlackPointCompensation = TRUE;
@@ -1198,7 +1190,7 @@ void HandleSwitches(int argc, char *argv[])
case 'h': {
int a = atoi(xoptarg);
- Help(a);
+ Help(ContextID, a);
}
break;
@@ -1240,12 +1232,16 @@ int main(int argc, char* argv[])
{
cmsContext ContextID = cmsCreateContext(NULL, NULL);
- InitUtils(NULL, "jpgicc");
+ fprintf(stderr, "Little CMS ICC profile applier for JPEG - v3.3 [LittleCMS %2.2f]\n\n", LCMS_VERSION / 1000.0);
+ fprintf(stderr, "Copyright (c) 1998-2020 Marti Maria Saguer. See COPYING file for details.\n");
+ fflush(stderr);
+
+ InitUtils(ContextID, "jpgicc");
- HandleSwitches(argc, argv);
+ HandleSwitches(ContextID, argc, argv);
if ((argc - xoptind) != 2) {
- Help(0);
+ Help(ContextID, 0);
}
OpenInput(argv[xoptind]);
@@ -1262,6 +1258,3 @@ int main(int argc, char* argv[])
return 0;
}
-
-
-