Comments (7)
Thanks, I got it to work! Took a second for me to figure out that you need to add treesitter
since there were no errors with the vimwiki
syntax, but having jpg
and other image formats in the editor is great.
I made a PR NixOS/nixpkgs#244038 to add image.nvim to nixpkgs and updated the magick PR with the patch.
from image.nvim.
The aim is not to have any display issues.
Making it compatible with zen-mode is out of scope, as it's not an issue but a missing feature at best, but my guess is that it should work even there.
Try it out.
from image.nvim.
I would love to try image.nvim! Unfortunately, I haven't been able to get magick
working yet. The instructions in the README have been a great help, however changing try_to_load
to /nix/store/vhc3pka4gjs6hghbsk7alc2nsry9k81i-imagemagick-7.1.1-12/lib/libMagickWand-7.Q16HDRI.so
doesn't change the error message for me.
I was trying to add magick to nixpkgs earlier. I think patching it like this could get it to work and I might be using the wrong .so
. See: NixOS/nixpkgs#243687
from image.nvim.
Yes, it's a bit of a pain, would be great to get it in nixpkgs. I'm looking to replace it as the rock can't be used to do masking.
To get it to work I patched ~/.luarocks/share/lua/5.1/magick/wand/lib.lua like this:
from image.nvim.
Not sure if I missed anything but I couldn't get that to work either. Can you share the file later? Planning to add the patch to the PR if I can get it to work.
from image.nvim.
I did a luarocks --local install magick
and then went to find the wand .so from the nix store:
cd (dirname (which magick))/../lib
# found libMagickWand-7.Q16HDRI.so
And then I just hardcoded the path to that .so in ~/.luarocks/share/lua/5.1/magick/wand/lib.lua
~/.luarocks/share/lua/5.1/magick/wand/lib.lua
local ffi = require("ffi")
local lib
ffi.cdef([[ typedef void MagickWand;
typedef void PixelWand;
typedef int MagickBooleanType;
typedef int ExceptionType;
typedef int ssize_t;
typedef int CompositeOperator;
typedef int GravityType;
typedef int OrientationType;
typedef int InterlaceType;
void MagickWandGenesis();
MagickWand* NewMagickWand();
MagickWand* CloneMagickWand(const MagickWand *wand);
MagickWand* DestroyMagickWand(MagickWand*);
MagickBooleanType MagickReadImage(MagickWand*, const char*);
MagickBooleanType MagickReadImageBlob(MagickWand*, const void*, const size_t);
char* MagickGetException(const MagickWand*, ExceptionType*);
int MagickGetImageWidth(MagickWand*);
int MagickGetImageHeight(MagickWand*);
MagickBooleanType MagickAddImage(MagickWand*, const MagickWand*);
MagickBooleanType MagickAdaptiveResizeImage(MagickWand*, const size_t, const size_t);
MagickBooleanType MagickWriteImage(MagickWand*, const char*);
unsigned char* MagickGetImageBlob(MagickWand*, size_t*);
void* MagickRelinquishMemory(void*);
MagickBooleanType MagickCropImage(MagickWand*,
const size_t, const size_t, const ssize_t, const ssize_t);
MagickBooleanType MagickBlurImage(MagickWand*, const double, const double);
MagickBooleanType MagickModulateImage(MagickWand*, const double, const double, const double);
MagickBooleanType MagickBrightnessContrastImage(MagickWand*, const double, const double);
MagickBooleanType MagickSetImageFormat(MagickWand* wand, const char* format);
char* MagickGetImageFormat(MagickWand* wand);
size_t MagickGetImageCompressionQuality(MagickWand * wand);
MagickBooleanType MagickSetImageCompressionQuality(MagickWand *wand,
const size_t quality);
MagickBooleanType MagickSharpenImage(MagickWand *wand,
const double radius,const double sigma);
MagickBooleanType MagickScaleImage(MagickWand *wand,
const size_t columns,const size_t rows);
MagickBooleanType MagickRotateImage(MagickWand *wand,
const PixelWand *background,const double degrees);
MagickBooleanType MagickSetOption(MagickWand *,const char *,const char *);
char* MagickGetOption(MagickWand *,const char *);
MagickBooleanType MagickCompositeImage(MagickWand *wand,
const MagickWand *source_wand,const CompositeOperator compose,
const ssize_t x,const ssize_t y);
GravityType MagickGetImageGravity(MagickWand *wand);
MagickBooleanType MagickSetImageGravity(MagickWand *wand,
const GravityType gravity);
MagickBooleanType MagickStripImage(MagickWand *wand);
MagickBooleanType MagickGetImagePixelColor(MagickWand *wand,
const ssize_t x,const ssize_t y,PixelWand *color);
MagickWand* MagickCoalesceImages(MagickWand*);
PixelWand *NewPixelWand(void);
PixelWand *DestroyPixelWand(PixelWand *);
double PixelGetAlpha(const PixelWand *);
double PixelGetRed(const PixelWand *);
double PixelGetGreen(const PixelWand *);
double PixelGetBlue(const PixelWand *);
void PixelSetAlpha(PixelWand *wand, const double alpha);
void PixelSetRed(PixelWand *wand, const double red);
void PixelSetGreen(PixelWand *wand, const double green);
void PixelSetBlue(PixelWand *wand, const double blue);
MagickBooleanType MagickTransposeImage(MagickWand *wand);
MagickBooleanType MagickTransverseImage(MagickWand *wand);
MagickBooleanType MagickFlipImage(MagickWand *wand);
MagickBooleanType MagickFlopImage(MagickWand *wand);
char* MagickGetImageProperty(MagickWand *wand, const char *property);
MagickBooleanType MagickSetImageProperty(MagickWand *wand,
const char *property,const char *value);
OrientationType MagickGetImageOrientation(MagickWand *wand);
MagickBooleanType MagickSetImageOrientation(MagickWand *wand,
const OrientationType orientation);
InterlaceType MagickGetImageInterlaceScheme(MagickWand *wand);
MagickBooleanType MagickSetImageInterlaceScheme(MagickWand *wand,
const InterlaceType interlace_scheme);
MagickBooleanType MagickAutoOrientImage(MagickWand *wand);
MagickBooleanType MagickResetImagePage(MagickWand *wand, const char *page);
MagickBooleanType MagickSetImageDepth(MagickWand *,const unsigned long);
unsigned long MagickGetImageDepth(MagickWand *);
]])
local get_flags
get_flags = function()
local proc = io.popen("pkg-config --cflags --libs MagickWand", "r")
local flags = proc:read("*a")
get_flags = function()
return flags
end
proc:close()
return flags
end
local get_filters
get_filters = function()
local suffixes = {
"magick/resample.h",
"MagickCore/resample.h",
}
local prefixes = {
"/usr/include/ImageMagick",
"/usr/local/include/ImageMagick",
-- unpack((function()
-- local _accum_0 = {}
-- local _len_0 = 1
-- for p in get_flags():gmatch("-I([^%s]+)") do
-- _accum_0[_len_0] = p
-- _len_0 = _len_0 + 1
-- end
-- return _accum_0
-- end)()),
}
for _index_0 = 1, #prefixes do
local p = prefixes[_index_0]
for _index_1 = 1, #suffixes do
local suffix = suffixes[_index_1]
local full = tostring(p) .. "/" .. tostring(suffix)
do
local f = io.open(full)
if f then
local content
do
local _with_0 = f:read("*a")
f:close()
content = _with_0
end
local filter_types = content:match("(typedef enum.-FilterTypes?;)")
if filter_types then
ffi.cdef(filter_types)
if filter_types:match("FilterTypes;") then return "FilterTypes" end
return "FilterType"
end
end
end
end
end
return false
end
local get_filter
get_filter = function(name)
return lib[name .. "Filter"]
end
local can_resize
do
local enum_name = get_filters()
if enum_name then
ffi.cdef([[ MagickBooleanType MagickResizeImage(MagickWand*,
const size_t, const size_t,
const ]] .. enum_name .. [[, const double);
]])
can_resize = true
end
end
local try_to_load
try_to_load = function(...)
local out
local _list_0 = {
...,
}
for _index_0 = 1, #_list_0 do
local _continue_0 = false
repeat
local name = _list_0[_index_0]
if "function" == type(name) then
name = name()
if not name then
_continue_0 = true
break
end
end
return ffi.load(name)
-- if pcall(function()
-- out = ffi.load(name)
-- end) then
-- return out
-- end
-- _continue_0 = true
until true
if not _continue_0 then break end
end
return error("Failed to load ImageMagick (" .. tostring(...) .. ")")
end
lib = try_to_load(
"/nix/store/48zg59xi37kxsw4m0bx28jgiszxpxpr1-imagemagick-7.1.1-11/lib/libMagickWand-7.Q16HDRI.so",
function()
-- return "/nix/store/48zg59xi37kxsw4m0bx28jgiszxpxpr1-imagemagick-7.1.1-11/lib/libMagickWand-7.Q16HDRI.so"
-- local lname = get_flags():match("-l(MagickWand[^%s]*)")
-- local suffix
-- if ffi.os == "OSX" then
-- suffix = ".dylib"
-- elseif ffi.os == "Windows" then
-- suffix = ".dll"
-- else
-- suffix = ".so"
-- end
-- return lname and "lib" .. lname .. suffix
end
)
return {
lib = lib,
can_resize = can_resize,
get_filter = get_filter,
}
from image.nvim.
Thanks, I got it to work! Took a second for me to figure out that you need to add
treesitter
since there were no errors with thevimwiki
syntax, but havingjpg
and other image formats in the editor is great.I made a PR NixOS/nixpkgs#244038 to add image.nvim to nixpkgs and updated the magick PR with the patch.
Amazing, glad it works, and thanks for the PR!
from image.nvim.
Related Issues (20)
- sticky images HOT 3
- Document integration clears user added images in markdown files HOT 3
- Link and preview overlap in markdown integration HOT 2
- Statusline hidden if cmdheight = 0 HOT 2
- Image is still shown when switched to another tmux window HOT 5
- Not working on Alacritty. HOT 2
- [bug] Unfolding images causes them to draw at the cursor position (and other weird folding behavior) HOT 1
- [bug] get images api changed in the namespace commit HOT 1
- [BUG] Image display override floating windows HOT 4
- Windows support? HOT 3
- Image ignores soft text wrapping HOT 1
- [feature request] Obsidian Link support HOT 3
- [bug] removing and adding image in buffer while images are displayed in a split HOT 1
- YALRMI: Yet Another LuaRocks Magick Issue HOT 7
- The picture cannot be displayed and the corresponding position is garbled. HOT 3
- Messes with lualine HOT 2
- Luarock magick abandoned HOT 19
- GIF rendered incorrectly HOT 3
- Background of telescope became transparent HOT 1
- `nvim: src/unix/core.c:148: uv_close: Assertion '!uv__is_closing(handle)' failed` when closing nvim; doesn't happens with `backend = "ueberzug"` HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from image.nvim.