Imagemagick's -lat '50x50' not working in minimagick - ruby

I need to run local adaptive threshold(-lat) method in MiniMagick.
I tried with the following code:
image.lat '50x50'
Its give an error stack level too deep when image.write 'output.jpg' is run.
Can anyone suggest a way to use (-lat) method in MiniMagick.

The common approach to stack options with MiniMagick is combine_options:
image.combine_options do |c|
c.lat '50x50'
# more options
end
This should not help in your case, though. Image#write copies the file from temporary location to the local file with given name. You might want to inspect your temporary file in /var/folders/.... to see whether the threshold was applied.
It sounds like an imagemagick glitch. Did you try
$ mogrify -lat 50x50 file.jpg
Does it work?

It looks like the -lat command is not included in mogrify. I ran into the same problem and found this question, two years after the OP, using IM version 6.9.2-3 Q16 x64 on Windows 7.
There is a discussion on the ImageMagick board here.

Related

How to resemble the PDF-output of AsciidocFX using a Gradle build-script?

I have the following Asciidoc-document:
= Test
:doctype: article
:notitle:
:!toc:
AsciidocFX shows links in PDFs as footnotes http://stackoverflow.com[SO].
.Asciidoc in PDF does not work in Asciidoctor, but works in AsciidocFX.
[cols="2,5a"]
|===
|Line with Asciidoc code
|here comes a list:
* item 1
* item 2
* item 3
http://stackoverflow.com[Get Answers]!
|Line
|with a footnotefootnote:[footnotes do work in AsciidocFX's PDF output (but not in the preview).]
|===
When generating a PDF using asciidoctor, the output is as follows:
The problems are:
footnotes are shown inline (see: https://github.com/asciidoctor/asciidoctor-pdf/issues/73)
Asciidoc-content in tables cells is not interpreted: https://github.com/asciidoctor/asciidoctor-pdf/issues/6
Link targets are not shown as Footnotes (this would be nice to have)
Using https://github.com/asciidocfx/AsciidocFX shows everything correctly:
Now, I'd like to have the same output that AsciidocFX produces, but still like to use my Gradle build-script.
From https://github.com/asciidoctor/asciidoctor-pdf/issues/73#issuecomment-224327058 I learned, that AsciidoctorFX uses https://github.com/asciidoctor/asciidoctor-fopub[asciidoctor-fopub] under the hood. But how can I this pipeline in my build.gradle. Do I have to generate epub in a first task and use the output in another task? Or is there a direkt way?
Sorry that I am a tad late (almost 7 years!!) to answer your question, but perhaps it will help others.
Perhaps you need to upgrade. When I run your .adoc verbatim, the foootnotes come out perfectly. In fact the output is exactly as you posted correct version of output. Here is the syntax that I use:
asciidoctor-pdf -a pdf-themesdir=/path/to/themes -a pdf-theme=your-pdf-theme-file.yml -a pdf-fontsdir=/path/to/your/fonts/directory/ your_test_file.adoc
I put this syntax in a bash script with the adoc file as an argument.
I am using:
linux Pop!_OS 22.04 LTS (close derivative of ubuntu)
ruby 3.1.2p20
asciidoctor-pdf-2.3.0b
Ironically, I am amazed with is your AsciidoctorFX output. AsciidoctorFX pdf output looks horrible for me and there is no simple way of changing the output style, like editing the asciidoctor-pdf yaml.
Cheers, Joe

No little images for TIP, NOTE nor IMPORTANT

I use https://github.com/asciidoctor/asciidoctor-epub3 to export to kf8 for Kindle. The result looks beautiful but is misses the little images next to TIP, NOTE and IMPORTANT. I guess the files are missing or there is an error in the CSS. How can I fix it?
I use this command to render the kf8 version:
asciidoctor-epub3 -D output -a ebook-format=kf8 book.adoc

IDL READFITS() syntax error

I'm trying to use the READFITS() function on IDL 8.3 on Mac 10.9.3
My input on the IDL promt:
readfits('image.fits',h, /EXTEN, /SILENT)
Result:
readfits('image.fits',h, /EXTEN, /SILENT)
^
% Syntax error.
*note: the '^' is below '/EXTEN'
Maybe it will help, so here is a link to the IDL help page on using READFITS() --> http://www.exelisvis.com/docs/readfits.html
I tried using the brackets like they show on that help page, but it still didn't work, so I'm stuck now. Didn't know if anyone here has experience reading .fits files in IDL.
ok, so it turns out the readfits procedure isn't included in IDL's original library, so I just had to download AstroLib (contains lots of useful astronomy procedures - including Readfits). The original syntax then worked.
I'm using IDL 8.2.2 on OS X 10.9.4.
Try keeping it simple first. Do these work?
readfits('image.fits')
readfits('image.fits', header)
Next try this:
readfits('image.fits', header, EXTEN_NO=0)
I suspect you really want extension number 0, not 1. See (e.g.) http://www.stsci.edu/documents/dhb/web/c02_datafiles.fm2.html.

Problems running FFprobe with Ruby

I am fairly new to Ruby and programming, less than a year experience. This is ruby 1.9.3 and the newest ffmpeg for Ubuntu from FFmpeg. Files I am using are basic .avi, some v210 .mov, other quicktime/finalcutpro types of files.
I am trying to write an automated probing tool that will help lessen the manual work load for me when I start testing with and dealing with lots of media files. Basically the script goes through a directory and probes each file, extracting the info I need, and writes it out to csv.
Currently, everytime I run it, the actual capture on command line is failing.
def prober(file)
#the_file = file
stdout,stderr,status = Open3.capture3("ffprobe -v quiet -print_format json - show_format -show_streams #{#the_file}")
STDERR.puts stderr
if status.success?
out = stdout
else
STDERR.puts "There was a problem, please try again."
end
#raw_output = JSON.parse(out)
end
I don't know if it is something to do with how I am running the command (I don't really fully understand I/O streams), or something with ffprobe. When it does make it past the probe it is returning #raw_output as nil, which causes JSON parsing to puke, or my other methods for splitting and parsing the metadata fail on nil.
Any help at all would great, I have been stuck on this for a while. Thanks! I can provide more code if needed for clarification,.
After the holidays I came back fresh and found the problem. The filepath string needs to have quotes around it when fed to the stdin for ffprobe, but when I aggregated the files it stripped the quotes. The fix? add quotes around the filepath in the string.
I hope this helps someone, apparently I am the only person in the whole internet to have this problem.

Ask RMagick to send a direct command to ImageMagick

Some options of ImageMagick are not supported by RMagick. Also sometimes it is in fact more convenient to use ImageMagick. Is there a method (of the Image object) that allows you to send commands directly to ImageMagick using the command line interface?
Would it be ok for you to use system or system call via backticks (or similar)?
You may also extend Magick::Image to do it easier.
My example code add a method convert to call the convert-command of imagemagick for the actual image. The action to be performed must be added.
require 'rmagick'
module Magick
class Image
def convert( cmd )
`convert #{self.filename} #{cmd}`
end
end
end
picname = Dir['*.jpg'].first
img = Magick::Image.read(picname).first
img.convert('x.png')

Resources