Skip to content

Commit 86e1c52

Browse files
committed
Merge branch 'develop'
2 parents caa6188 + ed00207 commit 86e1c52

File tree

10 files changed

+82
-14
lines changed

10 files changed

+82
-14
lines changed

docs/changelog.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
* [config](/guide/essentials/configuration)
1313
* autodetect converter by default
1414
* options attribute is now deprecated
15+
* [autoOrient](/guide/converters/image#auto-orient) is true by default
1516
* add [timeout](/guide/essentials/configuration#timeout-optional-default-30000ms)
1617
* update documentation
1718
* documentation v5
@@ -20,7 +21,11 @@
2021
* [migration page](/migration)
2122

2223

23-
> Released at *2025-07-14*
24+
> Released at *2025-08-18*
25+
26+
## 4.1.0
27+
28+
* add [autoOrient](/v4/guide/converters/image#auto-orient)
2429

2530
## 4.0.4
2631

docs/guide/converters/image.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,21 @@ declare module '@jrmc/adonis-attachment' {
8787
}
8888
```
8989

90+
## Auto-orient
91+
92+
Auto-orient based on the EXIF Orientation tag, then remove the tag. Mirroring is supported and may infer the use of a flip operation. ([sharp doc](https://sharp.pixelplumbing.com/api-operation/#autoorient))
93+
`autoOrient` is true by default.
94+
95+
```typescript
96+
const attachmentConfig = defineConfig({
97+
converters: {
98+
thumbnail: { // [!code focus:3]
99+
autoOrient: false
100+
}
101+
}
102+
})
103+
```
104+
90105
## BlurHash
91106

92107
The blurhash option is used to enable, disable, and customise the generation of blurhashes ([https://blurha.sh/](https://blurha.sh/)) for the variants. Blurhash generation is disabled by default.

docs/guide/essentials/configuration.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,6 @@ declare module '@jrmc/adonis-attachment' {
2727
}
2828
```
2929

30-
## converters
31-
32-
|OPTIONS: | DESCRIPTIONS: |
33-
| -------- | ------------------------ |
34-
|converter |Class for generate variant|
35-
|options |Options converter |
36-
3730
---
3831

3932
## preComputeUrl (optional, default false)

docs/migration.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,28 @@ thumbnail: {
6969
},
7070
},
7171
```
72-
:::
72+
:::
73+
74+
- [autoOrient](/v4/guide/converters/image#auto-orient) is now true by default.
75+
76+
If you do not want this option, please add it with the value false
77+
78+
::: code-group
79+
```typescript [Now]
80+
thumbnail: {
81+
resize: 300,
82+
format: 'webp',
83+
autoOrient: false,
84+
},
85+
```
86+
87+
```typescript [Before]
88+
thumbnail: {
89+
converter: () => import('@jrmc/adonis-attachment/converters/autodetect_converter'),
90+
options: {
91+
resize: 300,
92+
format: 'webp',
93+
},
94+
},
95+
```
96+
:::

docs/v4/guide/converters/image.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,23 @@ declare module '@jrmc/adonis-attachment' {
9595
}
9696
```
9797

98+
## Auto-orient
99+
100+
⚠️ [avalable in v4.1.0](/changelog#_4-1-0)
101+
102+
Auto-orient based on the EXIF Orientation tag, then remove the tag. Mirroring is supported and may infer the use of a flip operation. ([sharp doc](https://sharp.pixelplumbing.com/api-operation/#autoorient))
103+
`autoOrient` is false by default.
104+
105+
```typescript
106+
const attachmentConfig = defineConfig({
107+
converters: {
108+
thumbnail: { // [!code focus:3]
109+
autoOrient: true
110+
}
111+
}
112+
})
113+
```
114+
98115
## BlurHash
99116

100117
The blurhash option is used to enable, disable, and customise the generation of blurhashes ([https://blurha.sh/](https://blurha.sh/)) for the variants. Blurhash generation is disabled by default.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@jrmc/adonis-attachment",
3-
"version": "5.0.0-beta.6",
3+
"version": "5.0.0-beta.7",
44
"type": "module",
55
"description": "Turn any field on your Lucid model to an attachment data type",
66
"engines": {

src/converters/image_converter.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,22 @@ export default class ImageConverter extends Converter {
1616
const sharp = await use('sharp')
1717
const resize = options?.resize || {}
1818
let format = options?.format || 'webp'
19+
const autoOrient = options?.autoOrient ?? true
1920
let formatoptions = {}
2021

2122
if (typeof format !== 'string') {
2223
formatoptions = format?.options
2324
format = format.format
2425
}
2526

26-
const buffer: Input = await sharp(input)
27+
const image = sharp(input)
2728
.withMetadata()
29+
30+
if (autoOrient) {
31+
image.autoOrient()
32+
}
33+
34+
const buffer: Input = await image
2835
.resize(resize)
2936
.toFormat(format, formatoptions)
3037
.toBuffer()

src/types/converter.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ export type ConverterOptions = {
166166
| webp
167167
| avif
168168
| heif
169+
autoOrient?: boolean
169170
blurhash?: boolean | BlurhashOptions
170171
startTime?: number
171172
startPage?: number

stubs/config.stub

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,17 @@ const attachmentConfig = defineConfig({
104104
// }
105105
// }
106106

107+
/**
108+
*
109+
* https://sharp.pixelplumbing.com/api-operation/#autoorient
110+
*/
111+
// autoOrient: false,
112+
107113
/**
108114
* generation of blurhashes (default: true)
109115
* https://blurha.sh/
110116
*/
111-
// blurhash: true
117+
// blurhash: true,
112118
}
113119
}
114120
})

0 commit comments

Comments
 (0)