Skip to content

Commit 12e87c0

Browse files
committed
fix: mozjpeg compile issue
1 parent dbf0380 commit 12e87c0

File tree

2 files changed

+32
-15
lines changed

2 files changed

+32
-15
lines changed

packages/binding/index.d.ts

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export const enum ChromaSubsampling {
5555
* What if the chroma subsampling model is 4:0:0?
5656
* That says to use every pixel of luma data, but that each row has 0 chroma samples applied to it. The resulting image, then, is comprised solely of the luminance data—a greyscale image.
5757
*/
58-
Yuv400 = 3
58+
Yuv400 = 3,
5959
}
6060
export const enum FastResizeFilter {
6161
/**
@@ -94,7 +94,7 @@ export const enum FastResizeFilter {
9494
* Lanczos filter (a truncated sinc) on all pixels that may contribute
9595
* to the output value.
9696
*/
97-
Lanczos3 = 5
97+
Lanczos3 = 5,
9898
}
9999
export const enum ResizeFit {
100100
/**
@@ -108,7 +108,7 @@ export const enum ResizeFit {
108108
* Preserving aspect ratio
109109
* resize the image to be as large as possible while ensuring its dimensions are less than or equal to both those specified.
110110
*/
111-
Inside = 2
111+
Inside = 2,
112112
}
113113
export interface FastResizeOptions {
114114
width: number
@@ -126,14 +126,18 @@ export interface JpegCompressOptions {
126126
optimizeScans?: boolean
127127
}
128128
export function compressJpegSync(input: Buffer, options?: JpegCompressOptions | undefined | null): Buffer
129-
export function compressJpeg(input: Buffer, options?: JpegCompressOptions | undefined | null, signal?: AbortSignal | undefined | null): Promise<Buffer>
129+
export function compressJpeg(
130+
input: Buffer,
131+
options?: JpegCompressOptions | undefined | null,
132+
signal?: AbortSignal | undefined | null,
133+
): Promise<Buffer>
130134
export const enum CompressionType {
131135
/** Default compression level */
132136
Default = 0,
133137
/** Fast, minimal compression */
134138
Fast = 1,
135139
/** High compression level */
136-
Best = 2
140+
Best = 2,
137141
}
138142
export const enum FilterType {
139143
/**
@@ -153,7 +157,7 @@ export const enum FilterType {
153157
* Uses a heuristic to select one of the preceding filters for each
154158
* scanline rather than one filter for the entire image
155159
*/
156-
Adaptive = 5
160+
Adaptive = 5,
157161
}
158162
export interface PngEncodeOptions {
159163
/** Default is `CompressionType::Default` */
@@ -171,7 +175,7 @@ export const enum PngRowFilter {
171175
Entropy = 6,
172176
Bigrams = 7,
173177
BigEnt = 8,
174-
Brute = 9
178+
Brute = 9,
175179
}
176180
export interface PNGLosslessOptions {
177181
/**
@@ -216,7 +220,11 @@ export interface PNGLosslessOptions {
216220
strip?: boolean
217221
}
218222
export function losslessCompressPngSync(input: Buffer, options?: PNGLosslessOptions | undefined | null): Buffer
219-
export function losslessCompressPng(input: Buffer, options?: PNGLosslessOptions | undefined | null, signal?: AbortSignal | undefined | null): Promise<Buffer>
223+
export function losslessCompressPng(
224+
input: Buffer,
225+
options?: PNGLosslessOptions | undefined | null,
226+
signal?: AbortSignal | undefined | null,
227+
): Promise<Buffer>
220228
export interface PngQuantOptions {
221229
/** default is 70 */
222230
minQuality?: number
@@ -235,7 +243,11 @@ export interface PngQuantOptions {
235243
posterization?: number
236244
}
237245
export function pngQuantizeSync(input: Buffer, options?: PngQuantOptions | undefined | null): Buffer
238-
export function pngQuantize(input: Buffer, options?: PngQuantOptions | undefined | null, signal?: AbortSignal | undefined | null): Promise<Buffer>
246+
export function pngQuantize(
247+
input: Buffer,
248+
options?: PngQuantOptions | undefined | null,
249+
signal?: AbortSignal | undefined | null,
250+
): Promise<Buffer>
239251
export const enum Orientation {
240252
/** Normal */
241253
Horizontal = 1,
@@ -245,7 +257,7 @@ export const enum Orientation {
245257
MirrorHorizontalAndRotate270Cw = 5,
246258
Rotate90Cw = 6,
247259
MirrorHorizontalAndRotate90Cw = 7,
248-
Rotate270Cw = 8
260+
Rotate270Cw = 8,
249261
}
250262
/**
251263
* Available Sampling Filters.
@@ -325,7 +337,7 @@ export const enum ResizeFilterType {
325337
/** Gaussian Filter */
326338
Gaussian = 3,
327339
/** Lanczos with window 3 */
328-
Lanczos3 = 4
340+
Lanczos3 = 4,
329341
}
330342
export const enum JsColorType {
331343
/** Pixel is 8-bit luminance */
@@ -347,7 +359,7 @@ export const enum JsColorType {
347359
/** Pixel is 32-bit float RGB */
348360
Rgb32F = 8,
349361
/** Pixel is 32-bit float RGBA */
350-
Rgba32F = 9
362+
Rgba32F = 9,
351363
}
352364
export interface Metadata {
353365
width: number
@@ -388,7 +400,12 @@ export class Transformer {
388400
* The image is scaled to the maximum possible size that fits
389401
* within the bounds specified by `width` and `height`.
390402
*/
391-
resize(widthOrOptions: number | ResizeOptions, height?: number | undefined | null, filter?: ResizeFilterType | undefined | null, fit?: ResizeFit | undefined | null): this
403+
resize(
404+
widthOrOptions: number | ResizeOptions,
405+
height?: number | undefined | null,
406+
filter?: ResizeFilterType | undefined | null,
407+
fit?: ResizeFit | undefined | null,
408+
): this
392409
/**
393410
* Resize this image using the specified filter algorithm.
394411
* The image is scaled to the maximum possible size that fits

packages/binding/src/jpeg.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ unsafe fn create_error_handler() -> mozjpeg_sys::jpeg_error_mgr {
123123
err
124124
}
125125

126-
extern "C" fn unwind_error_exit(cinfo: &mut mozjpeg_sys::jpeg_common_struct) {
126+
unsafe extern "C-unwind" fn unwind_error_exit(cinfo: &mut mozjpeg_sys::jpeg_common_struct) {
127127
let message = unsafe {
128128
let err = cinfo.err.as_ref().unwrap();
129129
match err.format_message {
@@ -139,7 +139,7 @@ extern "C" fn unwind_error_exit(cinfo: &mut mozjpeg_sys::jpeg_common_struct) {
139139
std::panic::resume_unwind(Box::new(message))
140140
}
141141

142-
extern "C" fn silence_message(
142+
unsafe extern "C-unwind" fn silence_message(
143143
_cinfo: &mut mozjpeg_sys::jpeg_common_struct,
144144
_level: std::os::raw::c_int,
145145
) {

0 commit comments

Comments
 (0)