Skip to content

Commit

Permalink
Replace ImageMagick dependency with PNGFiles dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
simonschoelly authored Jun 20, 2021
2 parents e10f65c + accb675 commit 8e6bd36
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
7 changes: 2 additions & 5 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,18 @@ version = "0.3.1"
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
Cairo = "159f3aea-2a34-519c-b102-8c37f9878175"
CodecZlib = "944b1d66-785c-5afd-91f1-9de20f533193"
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
ImageCore = "a09fc81d-aa75-5fe9-8630-4744c3626534"
ImageMagick = "6218d12a-5da1-5696-b52f-db25d2ecc6d1"
Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"
PNGFiles = "f57f5aa1-a3ce-4bc8-8ab9-96f992907883"
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
Rsvg = "c4c386cf-5103-5370-be45-f3a111cca3b8"
libpng_jll = "b53b4c65-9356-5827-b1ea-8c7a1a84506f"

[compat]
Cairo = "1.0.4"
CodecZlib = "0.7"
FileIO = "1.4.0"
ImageCore = "0.8, 0.9"
ImageMagick = "1.1.5"
Interpolations = "0.13.2"
PNGFiles = "0.3.7"
Requires = "1.0.3"
Rsvg = "1.0.0"
julia = "1.4"
11 changes: 4 additions & 7 deletions src/KittyTerminalImages.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module KittyTerminalImages

using FileIO: load, save, Stream, @format_str
using Base64: base64encode
using Rsvg
using Cairo: FORMAT_ARGB32, CairoImageSurface, CairoContext
Expand All @@ -10,13 +9,10 @@ using ImageCore: RGBA, channelview
using CodecZlib: ZlibCompressor, ZlibCompressorStream
using Requires: @require
using Interpolations: interpolate, BSpline, Linear
using PNGFiles

import Base: display

# this seem to be necessary to enforce the usage of ImageMagic -- ImageIO
# produces an eof error.
using ImageMagick

export pushKittyDisplay!, forceKittyDisplay!, set_kitty_config!, get_kitty_config


Expand All @@ -35,7 +31,7 @@ function draw_temp_file(img)

# TODO ensure that there is no racing condition with these tempfiles
path, io = mktemp()
ImageMagick.save_(Stream(format"PNG", io), img)
PNGFiles.save(io, img)
close(io)

payload = transcode(UInt8, base64encode(path))
Expand Down Expand Up @@ -158,7 +154,8 @@ function display(d::KittyDisplay,
m::MIME"image/png", x; scale=get_kitty_config(:scale, 1.0))
buff = IOBuffer()
show_custom(buff, m, x)
img = load(Stream(format"PNG", buff))
seekstart(buff) # we need to reset the IOBuffer to it's start
img = PNGFiles.load(buff)
img = imresize(img; ratio=scale)

if get_kitty_config(:transfer_mode) == :direct
Expand Down

2 comments on commit 8e6bd36

@simonschoelly
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error while trying to register: "Tag with name v0.3.1 already exists and points to a different commit"

Please sign in to comment.