Skip to content

Commit

Permalink
Merge pull request #12 from naqvis/patch-crystal-ver
Browse files Browse the repository at this point in the history
fix: patch required to work with latest crystal version
  • Loading branch information
naqvis authored Mar 6, 2024
2 parents 033441f + fd6faa3 commit 2baacb1
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
DEBIAN_FRONTEND: noninteractive
run:
# we only need the library
sudo apt-get install --fix-missing -qq -o Acquire::Retries=3 libvips-dev
sudo apt-get update && sudo apt-get install libvips-dev
- name: Run tests
run: crystal spec --error-trace -v spec
- name: Check formatting
Expand Down
2 changes: 1 addition & 1 deletion shard.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: vips
version: 0.1.5
version: 0.1.6

authors:
- Ali Naqvi <[email protected]>
Expand Down
29 changes: 10 additions & 19 deletions spec/connection_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -114,28 +114,19 @@ describe Vips::Connection do
Vips::TargetCustom.new
end

pending "can write an image to a user output stream" do
it "can write an image to a user output stream" do
filename = timg("x5.png")
file = File.open(filename, "wb")
io = IO::Memory.new
target = Vips::TargetCustom.new
target.on_write { |slice| file.write(slice); slice.size.to_i64 }
target.on_finish { file.close }

image = Vips::Image.new_from_file(simg("wagon.jpg"))
image.write_to_target(target, "%.png")

image = Vips::Image.new_from_file(filename)

image.width.should eq(685)
image.height.should eq(478)
image.bands.should eq(3)
(image.avg - 109.789).should be <= 0.001
end

it "can write an image via target stream" do
filename = timg("x5.png")
file = File.open(filename, "wb")
target = Vips::TargetStream.new_from_stream(file)
target.on_write { |slice| io.write(slice); slice.size.to_i64 }
target.on_finish do
io.rewind
File.open(filename, "wb") do |file|
IO.copy(io, file)
end
io.clear
end

image = Vips::Image.new_from_file(simg("wagon.jpg"))
image.write_to_target(target, "%.png")
Expand Down
1 change: 0 additions & 1 deletion spec/image_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,6 @@ describe Vips::Image do
Vips::Enums::Interpretation::Lch,
Vips::Enums::Interpretation::Cmc,
Vips::Enums::Interpretation::Labs,
Vips::Enums::Interpretation::Scrgb,
Vips::Enums::Interpretation::Hsv,
Vips::Enums::Interpretation::Srgb,
Vips::Enums::Interpretation::Yxy]
Expand Down
30 changes: 15 additions & 15 deletions src/vips/lib.cr
Original file line number Diff line number Diff line change
Expand Up @@ -465,13 +465,13 @@ lib LibVips
enum GLogLevelFlags
Recursion = 1
Fatal = 2
Error = 4
Critical = 8
Warning = 16
Message = 32
Info = 64
Debug = 128
Mask = -4
Error = 4
Critical = 8
Warning = 16
Message = 32
Info = 64
Debug = 128
Mask = -4
end
alias GLogFunc = (Gchar*, GLogLevelFlags, Gchar*, Gpointer -> Void)

Expand Down Expand Up @@ -1373,13 +1373,13 @@ lib LibVips

@[Flags]
enum VipsOperationFlags
Sequential = 1
SequentialUnbuffered = 2
Nocache = 4
Deprecated = 8
Untrusted = 16
Blocked = 32
Revalidate = 64
Sequential = 1
SequentialUnbuffered = 2
Nocache = 4
Deprecated = 8
Untrusted = 16
Blocked = 32
Revalidate = 64
end

fun vips_operation_class_print_usage(operation_class : VipsOperationClass*)
Expand Down Expand Up @@ -2089,6 +2089,6 @@ lib LibVips

alias ReadCB = (Void*, Void*, Gint64, Void* -> Gint)
alias SeekCB = (Void*, Gint64, Gint, Void* -> Gint64)
alias WriteCB = (Void*, UInt8*, Gint, Void* -> Gint64)
alias WriteCB = (Void*, Void*, Gint, Void* -> Gint64)
alias FinishCB = (Void*, Void* ->)
end
2 changes: 1 addition & 1 deletion src/vips/source.cr
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ module Vips
signal_connect("read", LibVips::ReadCB.new { |_source, buff, size, data|
next 0 if size <= 0
callback = Box(typeof(block)).unbox(data)
slice = Bytes.new(buff.as(UInt8*), size)
slice = Bytes.new(buff.as(UInt8*), size - 1)
callback.call(slice)
}, boxed_data)
end
Expand Down
2 changes: 1 addition & 1 deletion src/vips/target.cr
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ module Vips
signal_connect("write", LibVips::WriteCB.new { |source, buff, size, data|
next -1_i64 if size <= 0
callback = Box(typeof(block)).unbox(data)
slice = Bytes.new(buff, size)
slice = Bytes.new(buff.as(UInt8*), size)
@@box.delete(data)
callback.call(slice)
}, boxed_data)
Expand Down

0 comments on commit 2baacb1

Please sign in to comment.