Skip to content

Commit eb27f11

Browse files
committed
add options for automatic quality and file type conversion and iptc meta
1 parent e9d1cce commit eb27f11

File tree

3 files changed

+37
-4
lines changed

3 files changed

+37
-4
lines changed

packages/forms/configCloudinary.cfc

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,21 @@
1818
name="autoUploadFolder" type="string"
1919
ftHint="The auto upload folder for this appliation. Should start with '/'." />
2020

21-
21+
22+
<cfproperty ftSeq="10" ftFieldset="Options" ftLabel="Automatic Image File Format"
23+
name="formatAuto" type="boolean" default="1" ftDefault="1"
24+
ftType="boolean" ftRenderType="checkbox"
25+
ftHint="Cloudinary will automatically select the best image format" />
26+
27+
<cfproperty ftSeq="11" ftFieldset="Options" ftLabel="Automatic Image Quality"
28+
name="qualityAuto" type="boolean" default="1" ftDefault="1"
29+
ftType="boolean" ftRenderType="checkbox"
30+
ftHint="Cloudinary will automatically select the best image quality vs file size" />
31+
32+
<cfproperty ftSeq="12" ftFieldset="Options" ftLabel="Keep IPTC Metadata"
33+
name="keepIPTC" type="boolean" default="0" ftDefault="0"
34+
ftType="boolean" ftRenderType="checkbox"
35+
ftHint="Cloudinary will retain IPTC Metadata. NOTE: This will NOT WORK if automatic image quality is selected above." />
36+
37+
2238
</cfcomponent>

packages/formtools/image.cfc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@
372372
<cfargument name="padColor" type="string" required="false" default="##ffffff" hint="If AutoGenerateType='Pad', image will be padded with this colour" />
373373
<cfargument name="customEffectsObjName" type="string" required="true" default="imageEffects" hint="The object name to run the effects on (must be in the package path)" />
374374
<cfargument name="lCustomEffects" type="string" required="false" default="" hint="List of methods to run for effects with their arguments and values. The methods are order dependant replecting how they are listed here. Example: ftLCustomEffects=""roundCorners();reflect(opacity=40,backgroundColor='black');""" />
375-
<cfargument name="convertImageToFormat" type="string" required="false" default="" hint6="Convert image to a specific format. Set value to image extension. Example: 'gif'. Leave blank for no conversion. Default=blank (no conversion)" />
375+
<cfargument name="convertImageToFormat" type="string" required="false" default="" hint="Convert image to a specific format. Set value to image extension. Example: 'gif'. Leave blank for no conversion. Default=blank (no conversion)" />
376376
<cfargument name="bSetAntialiasing" type="boolean" required="true" default="true" hint="Use Antialiasing (better image, but slower performance)" />
377377
<cfargument name="interpolation" type="string" required="true" default="blackman" hint="set the interpolation level on the image compression" />
378378
<cfargument name="quality" type="string" required="false" default="0.8" hint="Quality of the JPEG destination file. Applies only to files with an extension of JPG or JPEG. Valid values are fractions that range from 0 through 1 (the lower the number, the lower the quality). Examples: 1, 0.9, 0.1. Default = 0.8" />

packages/lib/cloudinary.cfc

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,25 @@
2525

2626
public string function getTransform(numeric width=0, numeric height=0, string crop="FitInside", string format=""){
2727

28-
var transform = "fl_keep_iptc";
28+
var transform = "";
2929
var pixels = "";
30-
30+
31+
if (arguments.format == "" && application.fapi.getConfig("cloudinary", "formatAuto", 1) == 1) {
32+
// enable automatic file format conversion
33+
arguments.format = "auto";
34+
}
35+
36+
if (application.fapi.getConfig("cloudinary", "qualityAuto", 1) == 1) {
37+
// enable automatic image quality
38+
transform = listappend(transform, "q_auto");
39+
}
40+
else {
41+
if (application.fapi.getConfig("cloudinary", "keepIPTC", 0) == 1) {
42+
// retain IPTC metadata only if auto image quality is NOT used
43+
transform = listappend(transform, "fl_keep_iptc");
44+
}
45+
}
46+
3147
switch (lcase(arguments.crop)){
3248
case "forcesize":
3349
// Simply force the resize of the image into the width/height provided
@@ -159,6 +175,7 @@
159175
break;
160176
case "auto":
161177
transform = listappend(transform, "f_auto");
178+
break;
162179
}
163180

164181
return transform;

0 commit comments

Comments
 (0)