Skip to content

Commit 4af2efd

Browse files
Sakari369zbjornson
authored andcommitted
Fix to compile without JPEG library.
1 parent 9cd9aa3 commit 4af2efd

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

src/Canvas.cc

+2
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ static void parsePNGArgs(Local<Value> arg, PngClosure& pngargs) {
282282
}
283283
}
284284

285+
#ifdef HAVE_JPEG
285286
static void parseJPEGArgs(Local<Value> arg, JpegClosure& jpegargs) {
286287
// "If Type(quality) is not Number, or if quality is outside that range, the
287288
// user agent must use its default quality value, as if the quality argument
@@ -311,6 +312,7 @@ static void parseJPEGArgs(Local<Value> arg, JpegClosure& jpegargs) {
311312
}
312313
}
313314
}
315+
#endif
314316

315317
static uint32_t getSafeBufSize(Canvas* canvas) {
316318
// Don't allow the buffer size to exceed the size of the canvas (#674)

src/closure.cc

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#include "closure.h"
22

3+
#ifdef HAVE_JPEG
4+
35
void JpegClosure::init_destination(j_compress_ptr cinfo) {
46
JpegClosure* closure = (JpegClosure*)cinfo->client_data;
57
closure->vec.resize(PAGE_SIZE);
@@ -21,3 +23,5 @@ void JpegClosure::term_destination(j_compress_ptr cinfo) {
2123
size_t finalSize = closure->vec.size() - closure->jpeg_dest_mgr->free_in_buffer;
2224
closure->vec.resize(finalSize);
2325
}
26+
27+
#endif

src/closure.h

+6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
#pragma once
44

55
#include "Canvas.h"
6+
7+
#ifdef HAVE_JPEG
68
#include <jpeglib.h>
9+
#endif
10+
711
#include <nan.h>
812
#include <png.h>
913
#include <stdint.h> // node < 7 uses libstdc++ on macOS which lacks complete c++11
@@ -52,6 +56,7 @@ struct PngClosure : Closure {
5256
PngClosure(Canvas* canvas) : Closure(canvas) {};
5357
};
5458

59+
#ifdef HAVE_JPEG
5560
struct JpegClosure : Closure {
5661
uint32_t quality = 75;
5762
uint32_t chromaSubsampling = 2;
@@ -73,3 +78,4 @@ struct JpegClosure : Closure {
7378
delete jpeg_dest_mgr;
7479
}
7580
};
81+
#endif

0 commit comments

Comments
 (0)