-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
513 additions
and
241 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
2.3.8 | ||
2.6.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
require 'memory_profiler' | ||
require 'rszr' | ||
require 'mini_magick' | ||
require 'gd2-ffij' | ||
|
||
ITERATIONS = 100 | ||
|
||
original = Pathname.new(__FILE__).dirname.join('../spec/images/test.jpg') | ||
resized = Pathname.new(__FILE__).dirname.join('output.jpg') | ||
|
||
mini_magick = MemoryProfiler.report do | ||
ITERATIONS.times do | ||
image = MiniMagick::Image.open(original.to_s) | ||
image.resize '800x532' | ||
image.write resized.to_s | ||
image = nil | ||
end | ||
end | ||
|
||
mini_magick.pretty_print(scale_bytes: true) | ||
|
||
gd2 = MemoryProfiler.report do | ||
image = GD2::Image.import(original.to_s) | ||
image.resize! 800, 532 | ||
image.export resized.to_s | ||
image = nil | ||
end | ||
|
||
gd2.pretty_print(scale_bytes: true) | ||
|
||
rszr = MemoryProfiler.report do | ||
ITERATIONS.times do | ||
image = Rszr::Image.load(original.to_s) | ||
image.resize! 800, 532 | ||
image.save resized.to_s | ||
image = nil | ||
end | ||
end | ||
|
||
rszr.pretty_print(scale_bytes: true) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#ifndef RUBY_RSZR_ERRORS | ||
#define RUBY_RSZR_ERRORS | ||
|
||
#include "rszr.h" | ||
#include "errors.h" | ||
|
||
VALUE eRszrError = Qnil; | ||
VALUE eRszrFileNotFound = Qnil; | ||
VALUE eRszrTransformationError = Qnil; | ||
VALUE eRszrErrorWithMessage = Qnil; | ||
VALUE eRszrLoadError = Qnil; | ||
VALUE eRszrSaveError = Qnil; | ||
|
||
static const char * const sRszrErrorMessages[] = | ||
{ | ||
"File does not exist", | ||
"File is a directory", | ||
"Read permission denied", | ||
"Unsupported format", | ||
"Path too long", | ||
"Non-existant path component", | ||
"Path component is not a directory", | ||
"Path outside address space", | ||
"Too many symbolic links", | ||
"Out of memory", | ||
"Out of file descriptors", | ||
"Write permission denied", | ||
"Out of disk space", | ||
"Unknown error" | ||
}; | ||
const int RSZR_MAX_ERROR_INDEX = 13; | ||
|
||
void Init_rszr_errors() | ||
{ | ||
eRszrError = rb_define_class_under(mRszr, "Error", rb_eStandardError); | ||
eRszrFileNotFound = rb_define_class_under(mRszr, "FileNotFound", eRszrError); | ||
eRszrTransformationError = rb_define_class_under(mRszr, "TransformationError", eRszrError); | ||
eRszrErrorWithMessage = rb_define_class_under(mRszr, "ErrorWithMessage", eRszrError); | ||
eRszrLoadError = rb_define_class_under(mRszr, "LoadError", eRszrErrorWithMessage); | ||
eRszrSaveError = rb_define_class_under(mRszr, "SaveError", eRszrErrorWithMessage); | ||
} | ||
|
||
static void rszr_raise_error_with_message(VALUE rb_error_class, Imlib_Load_Error error) | ||
{ | ||
int error_index = (int) error - 1; | ||
if (error_index < 1 || error_index > RSZR_MAX_ERROR_INDEX) | ||
error_index = 13; | ||
VALUE rb_error = rb_exc_new2(rb_error_class, sRszrErrorMessages[error_index]); | ||
rb_exc_raise(rb_error); | ||
} | ||
|
||
void rszr_raise_load_error(Imlib_Load_Error error) | ||
{ | ||
rszr_raise_error_with_message(eRszrLoadError, error); | ||
} | ||
|
||
void rszr_raise_save_error(Imlib_Load_Error error) | ||
{ | ||
rszr_raise_error_with_message(eRszrSaveError, error); | ||
} | ||
|
||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#ifndef RUBY_RSZR_ERRORS_H | ||
#define RUBY_RSZR_ERRORS_H | ||
|
||
void Init_rszr_errors(); | ||
void rszr_raise_load_error(Imlib_Load_Error error); | ||
void rszr_raise_save_error(Imlib_Load_Error error); | ||
|
||
extern VALUE eRszrError; | ||
extern VALUE eRszrFileNotFound; | ||
extern VALUE eRszrTransformationError; | ||
extern VALUE eRszrErrorWithMessage; | ||
extern VALUE eRszrLoadError; | ||
extern VALUE eRszrSaveError; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
require 'mkmf' | ||
require 'rbconfig' | ||
=begin | ||
LIBDIR = RbConfig::CONFIG['libdir'] | ||
INCLUDEDIR = RbConfig::CONFIG['includedir'] | ||
HEADER_DIRS = [ | ||
'/opt/local/include', | ||
'/usr/local/include', | ||
INCLUDEDIR, | ||
'/usr/include', | ||
] | ||
LIB_DIRS = [ | ||
'/opt/local/lib', | ||
'/usr/local/lib', | ||
LIBDIR, | ||
'/usr/lib', | ||
] | ||
dir_config('Imlib2', HEADER_DIRS, LIB_DIRS) | ||
=end | ||
imlib2_config = with_config('imlib2-config', 'imlib2-config') | ||
|
||
$CFLAGS << ' -DX_DISPLAY_MISSING ' << `#{imlib2_config} --cflags`.chomp | ||
$LDFLAGS << ' ' << `#{imlib2_config} --libs`.chomp | ||
$LDFLAGS.gsub!(/\ -lX11\ -lXext/, '') if RUBY_PLATFORM =~ /darwin/ | ||
|
||
unless find_header('Imlib2.h') | ||
abort 'imlib2 development headers are missing' | ||
end | ||
|
||
unless find_library('imlib2', 'imlib_set_cache_size') | ||
abort 'imlib2 is missing' | ||
end | ||
|
||
create_makefile 'rszr' |
Oops, something went wrong.