@tryghost/image-transform 1.2.10 → 1.2.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/transform.js +9 -1
  2. package/package.json +3 -3
package/lib/transform.js CHANGED
@@ -107,8 +107,16 @@ const unsafeResizeFromBuffer = async (originalBuffer, options = {}) => {
107
107
  // CASE: Automatically remove metadata and rotate based on the orientation.
108
108
  .rotate();
109
109
 
110
+ const metadata = await s.metadata();
111
+
110
112
  if (options.format) {
111
- s = s.toFormat(options.format);
113
+ if (options.format === 'jpeg') {
114
+ s.jpeg({mozjpeg: true}); // .jpeg sets format
115
+ } else {
116
+ s = s.toFormat(options.format);
117
+ }
118
+ } else if (metadata.format === 'jpeg') {
119
+ s.jpeg({mozjpeg: true}); // .jpeg sets format
112
120
  }
113
121
 
114
122
  const resizedBuffer = await s.toBuffer();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryghost/image-transform",
3
- "version": "1.2.10",
3
+ "version": "1.2.11",
4
4
  "repository": "https://github.com/TryGhost/SDK/tree/main/packages/image-transform",
5
5
  "author": "Ghost Foundation",
6
6
  "license": "MIT",
@@ -22,7 +22,7 @@
22
22
  "c8": "8.0.1",
23
23
  "mocha": "10.2.0",
24
24
  "should": "13.2.3",
25
- "sinon": "17.0.0"
25
+ "sinon": "17.0.1"
26
26
  },
27
27
  "dependencies": {
28
28
  "@tryghost/errors": "^1.2.26",
@@ -31,5 +31,5 @@
31
31
  "optionalDependencies": {
32
32
  "sharp": "^0.32.0"
33
33
  },
34
- "gitHead": "77a1645eadd5ce2c2a747a95405f6d8b15ea4e45"
34
+ "gitHead": "4839d3f97de2120d98fa47677eed7591dfa20e64"
35
35
  }