Skip to content

Commit ec8b6e3

Browse files
authored
Merge branch 'main' into single-line-lib-definitions
2 parents 67c2a8b + 6fe5326 commit ec8b6e3

File tree

14 files changed

+26
-23
lines changed

14 files changed

+26
-23
lines changed

.github/workflows/ci.yml

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ jobs:
1616
- run: >
1717
apk add
1818
crystal
19+
git-lfs
1920
libjpeg-turbo
2021
libjpeg-turbo-dev
2122
libspng

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
<picture>
33
<source
44
media="(prefers-color-scheme: dark)"
5-
srcset="https://raw.githubusercontent.com/phenopolis/pluto-logo/main/logo-white.png"
5+
srcset="https://media.githubusercontent.com/media/phenopolis/pluto/media/logo-white.png"
66
/>
77
<img
88
alt="logo"
9-
src="https://raw.githubusercontent.com/phenopolis/pluto-logo/main/logo-black.png"
9+
src="https://media.githubusercontent.com/media/phenopolis/pluto/media/logo-black.png"
1010
width="720px"
1111
/>
1212
</picture>

shard.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ version: 1.0.1
44
dependencies:
55
stumpy_core:
66
github: stumpycr/stumpy_core
7+
version: ~> 1.9
78

89
development_dependencies:
910
ameba:
1011
github: crystal-ameba/ameba
1112
version: ~> 1.6.1
1213
pluto_samples:
13-
github: phenopolis/pluto-samples
14+
github: phenopolis/pluto
15+
branch: samples
1416
stumpy_png:
1517
github: stumpycr/stumpy_png
1618

spec/pluto/operation/crop_spec.cr

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ describe Pluto::Operation::Crop do
55
it "checks image width boundaries" do
66
image = ga_sample
77

8-
expect_raises(Exception, "Crop dimensions extend 1 pixels beyond width of the image (640)") do
8+
expect_raises(Pluto::Exception, "Crop dimensions extend 1 pixels beyond width of the image (640)") do
99
image.crop(0, 0, image.width + 1, image.height)
1010
end
1111
end
1212

1313
it "checks image height boundaries" do
1414
image = ga_sample
1515

16-
expect_raises(Exception, "Crop dimensions extend 1 pixels beyond height of the image (480)") do
16+
expect_raises(Pluto::Exception, "Crop dimensions extend 1 pixels beyond height of the image (480)") do
1717
image.crop(0, 0, image.width, image.height + 1)
1818
end
1919
end

spec/pluto/operation/horizontal_blur_spec.cr

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ describe Pluto::Operation::HorizontalBlur do
1919
end
2020

2121
it "doesn't cause arithmetic overload" do
22-
with_sample("problem_images/28_arithmetic_overflow_in_blur.jpeg") do |io|
22+
with_sample("problematic_images/28_arithmetic_overflow_in_blur.jpeg") do |io|
2323
image = Pluto::ImageRGBA.from_jpeg(io)
2424
expect_digest image.horizontal_blur(10), "d1e2b9363a2e7a36e738599cda8dab844a828b15"
2525
end
2626
end
2727

2828
it "doesn't cause arithmetic overload again" do
29-
with_sample("problem_images/46_arithmetic_overflow_in_blur_again.jpeg") do |io|
29+
with_sample("problematic_images/46_arithmetic_overflow_in_blur_again.jpeg") do |io|
3030
image = Pluto::ImageRGBA.from_jpeg(io)
3131
expect_digest image.horizontal_blur(5), "a6ce6aeb78bc3cc6cff8e39f932b3e778b127950"
3232
end

spec/pluto/operation/rotation_spec.cr

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ describe Pluto::Operation::Rotation do
55
it "checks padding and radius" do
66
image = ga_sample
77

8-
expect_raises(Exception, "Can't pad image and limit rotation by radius") do
8+
expect_raises(Pluto::Exception, "Can't pad image and limit rotation by radius") do
99
image.rotation(0, padding: true, radius: 1)
1010
end
1111
end

spec/pluto/operation/vertical_blur_spec.cr

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ describe Pluto::Operation::VerticalBlur do
1919
end
2020

2121
it "doesn't cause arithmetic overload" do
22-
with_sample("problem_images/28_arithmetic_overflow_in_blur.jpeg") do |io|
22+
with_sample("problematic_images/28_arithmetic_overflow_in_blur.jpeg") do |io|
2323
image = Pluto::ImageRGBA.from_jpeg(io)
2424
expect_digest image.vertical_blur(10), "00e2c8a20e4554242bca3e0acf841028a2922fe6"
2525
end

src/pluto/format/jpeg.cr

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ module Pluto::Format::JPEG
5050
message = String.new(Format::Binding::LibJPEGTurbo.get_error_str(handle))
5151
error_code = Format::Binding::LibJPEGTurbo.get_error_code(handle).to_i
5252

53-
raise ::Pluto::Exception.new(message, error_code) unless code == 0
53+
raise Exception.new(message, error_code) unless code == 0
5454
end
5555
end
5656

src/pluto/format/png.cr

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module Pluto::Format::PNG
44
macro included
55
def self.from_png(image_data : Bytes) : self
66
ctx = Format::Binding::LibSPNG.ctx_new(Format::Binding::LibSPNG::CtxFlags::None)
7-
raise ::Pluto::Exception.new("Failed to create a context") unless ctx
7+
raise Exception.new("Failed to create a context") unless ctx
88

99
Format::Binding::LibSPNG.set_png_buffer(ctx, image_data, image_data.size)
1010

@@ -47,7 +47,7 @@ module Pluto::Format::PNG
4747
end
4848

4949
protected def self.check_png(code)
50-
raise ::Pluto::Exception.new(code) if code != 0
50+
raise Exception.new(code) if code != 0
5151
end
5252
end
5353

@@ -61,7 +61,7 @@ module Pluto::Format::PNG
6161
end
6262

6363
ctx = Format::Binding::LibSPNG.ctx_new(Format::Binding::LibSPNG::CtxFlags::Encoder)
64-
raise ::Pluto::Exception.new("Failed to create a context") unless ctx
64+
raise Exception.new("Failed to create a context") unless ctx
6565

6666
Format::Binding::LibSPNG.set_option(ctx, Format::Binding::LibSPNG::Option::EncodeToBuffer, true)
6767
Format::Binding::LibSPNG.set_png_buffer(ctx, image_data.buffer, image_data.size)
@@ -83,7 +83,7 @@ module Pluto::Format::PNG
8383
check_png error
8484

8585
buffer = Format::Binding::LibSPNG.get_png_buffer(ctx, out size, pointerof(error))
86-
raise ::Pluto::Exception.new("Failed to get a buffer") unless ctx
86+
raise Exception.new("Failed to get a buffer") unless ctx
8787

8888
bytes = Bytes.new(buffer, size)
8989
io.write(bytes)

src/pluto/format/ppm.cr

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ module Pluto::Format::PPM
2525
green.unsafe_put(index, green_byte)
2626
blue.unsafe_put(index, blue_byte)
2727
else
28-
raise "The image ends prematurely"
28+
raise Exception.new("The image ends prematurely")
2929
end
3030
end
3131

3232
new(red, green, blue, alpha, width, height)
3333
else
34-
raise "The image doesn't have width or height"
34+
raise Exception.new("The image doesn't have width or height")
3535
end
3636
end
3737
end

src/pluto/format/webp.cr

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ module Pluto::Format::WebP
3434
end
3535

3636
protected def self.check_webp(code)
37-
raise ::Pluto::Exception.new(code.to_i) if code == 0
37+
raise Exception.new(code.to_i) if code == 0
3838
end
3939
end
4040

src/pluto/image_ga.cr

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ class Pluto::ImageGA < Pluto::Image
5151
case channel_type
5252
when ChannelType::Gray then @gray
5353
when ChannelType::Alpha then @alpha
54-
else raise "Unknown channel type #{channel_type} for ImageRGBA"
54+
else raise Exception.new("Unknown channel type #{channel_type} for ImageRGBA")
5555
end
5656
end
5757

5858
def []=(channel_type : ChannelType, channel : Array(UInt8)) : Array(UInt8)
5959
case channel_type
6060
when ChannelType::Gray then self.gray = channel
6161
when ChannelType::Alpha then self.alpha = channel
62-
else raise "Unknown channel type #{channel_type} for ImageGA"
62+
else raise Exception.new("Unknown channel type #{channel_type} for ImageGA")
6363
end
6464
end
6565

src/pluto/image_rgba.cr

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class Pluto::ImageRGBA < Pluto::Image
3636
when ChannelType::Green then @green
3737
when ChannelType::Blue then @blue
3838
when ChannelType::Alpha then @alpha
39-
else raise "Unknown channel type #{channel_type} for ImageRGBA"
39+
else raise Exception.new("Unknown channel type #{channel_type} for ImageRGBA")
4040
end
4141
end
4242

@@ -46,7 +46,7 @@ class Pluto::ImageRGBA < Pluto::Image
4646
when ChannelType::Green then @green = channel
4747
when ChannelType::Blue then @blue = channel
4848
when ChannelType::Alpha then @alpha = channel
49-
else raise "Unknown channel type #{channel_type} for ImageRGBA"
49+
else raise Exception.new("Unknown channel type #{channel_type} for ImageRGBA")
5050
end
5151
end
5252

src/pluto/operation/crop.cr

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ module Pluto::Operation::Crop
44
end
55

66
def crop!(x : Int32, y : Int32, new_width : Int32, new_height : Int32) : self
7-
raise "Crop dimensions extend #{x + new_width - width} pixels beyond width of the image (#{width})" if (x + new_width) > width
8-
raise "Crop dimensions extend #{y + new_height - height} pixels beyond height of the image (#{height})" if (y + new_height) > height
7+
raise Exception.new("Crop dimensions extend #{x + new_width - width} pixels beyond width of the image (#{width})") if (x + new_width) > width
8+
raise Exception.new("Crop dimensions extend #{y + new_height - height} pixels beyond height of the image (#{height})") if (y + new_height) > height
99

1010
new_size = new_width * new_height
1111
height_offset = y * width

0 commit comments

Comments
 (0)