Module: Axon::JPEG
- Defined in:
- ext/axon/jpeg.c
Defined Under Namespace
Classes: Reader
Class Method Summary collapse
-
.write(image_in, io_out[, options]) ⇒ Integer
Writes the given image
image_in
toio_out
as compressed JPEG data.
Class Method Details
.write(image_in, io_out[, options]) ⇒ Integer
Writes the given image image_in
to io_out
as compressed JPEG data. Returns the number of bytes written.
options
may contain the following symbols:
* :bufsize - the size in bytes of the writes that will be made to
+io_out+.
* :quality - the JPEG quality on a 0..100 scale.
* :exif - raw exif data that will be saved in the header.
* :icc_profile - raw icc profile that will be saved in the header.
Example:
image = Axon::Solid.new(200, 300)
io = File.open("test.jpg", "w")
Axon::JPEG.write(image, io) #=> 1234
385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 |
# File 'ext/axon/jpeg.c', line 385
static VALUE
write_jpeg(int argc, VALUE *argv, VALUE self)
{
VALUE image_in, io_out, rb_bufsize, icc_profile, exif, quality, options;
int bufsize;
rb_scan_args(argc, argv, "21", &image_in, &io_out, &options);
bufsize = WRITE_BUFSIZE;
if (!NIL_P(options) && TYPE(options) == T_HASH) {
rb_bufsize = rb_hash_aref(options, sym_bufsize);
/* in 1.8.7, NUM2INT gives funny numbers for Symbols */
if (SYMBOL_P(rb_bufsize))
rb_raise(rb_eTypeError, "symbol for bufsize.");
if (!NIL_P(rb_bufsize)) {
bufsize = NUM2INT(rb_bufsize);
if (bufsize < 1)
rb_raise(rb_eRuntimeError, "Buffer size must be greater than zero");
}
icc_profile = rb_hash_aref(options, sym_icc_profile);
exif = rb_hash_aref(options, sym_exif);
quality = rb_hash_aref(options, sym_quality);
} else {
icc_profile = Qnil;
exif = Qnil;
quality = Qnil;
}
return write_jpeg2(image_in, io_out, bufsize, icc_profile, exif, quality);
}
|