Do browsers use built-in jpeg encoders or a system wide one? - browser

I've had this question for a while now, but have not been able to find an answer. Any hints or references for further reading would be greatly appreciated.

They are likely to incorporate a library into their own code. If I were writing a browser, I would not count on there being a pre-existing library to do JPEG decoder that would be usable.

Related

Is there any way converting a PDF to jpeg with golang?

I am currently rewriting my "old" Python-based Chatbots into golang.
One issue I came across was that I can´t convert a PDF into jpeg. Which I´d like to do so I can send it into a chat easily.
Already tried this with bimg (did not work at all) and imagemagick (gopkg.in/gographics/imagick.v3/imagick) as provided in this answer to another thread: "https://stackoverflow.com/a/47520596/7502507"
imagick.Initialize()
defer imagick.Terminate()
mw := imagick.NewMagickWand()
defer mw.Destroy()
mw.ReadImage(pdf)
mw.SetIteratorIndex(0) // This being the page offset
mw.SetImageFormat("jpg")
mw.WriteImage(image)
It does not produce a jpg at all, it just gives me the error
ERROR_POLICY: attempt to perform an operation not allowed by the security policy `PDF' # error/constitute.c/IsCoderAuthorized/408
How can I make this work? I can´t seem to edit the security settings for this.
Any help is appreciated!
I've been through the same issue and din't find any pure Golang solution.
Not a pure Golang solution, but this works flawlessly which uses cgo internally. Underlying library is Pdfium which is a C++ library, developed by Google and used in Chrome.
After a lot of research, I discovered that Pdfium was the best in class in terms of speed, robustness, license requirements and reliability.
To improve overall performance of the operation, I've ended up with this encoder as Golang's image encoders aren't geared towards performance and are slow.

How to extract video clips using the LibVLC API?

My question is exactly the same as this one, except that... is it possible to achieve the goal with LibVLC? Thanks!
By the way, are there any full-fledged tutorials or books for LibVLC? There are plenty modules mentioned in this page, but without a tutorial it's difficult/impossible for me to understand how they work. So far, the only tutorial I found is https://wiki.videolan.org/LibVLC_Tutorial/ which is very primitive and says nothing about demuxing, decoding, encoding or muxing. Any information or suggestion is highly appreciated!

read text document from scanned image

Is there any way we can get the text from a scanned document in jpg jpeg or any other format ? I am using ruby as my programming language . But I guess if I can get the texts with some help from other programming languages , it will not be much of a problem to integrate.
Thanks.
Yes, you can use an OCR library. There are additional details at https://stackoverflow.com/questions/1085/free-ocr-library.
In brief, you may wish to consider using tessnet (http://www.pixel-technology.com/freeware/tessnet2/).
This technology is called optical character recognition (OCR).
For programming, check out this question, which recommends tesseract-ocr.
OCR for ruby? check out this question.
If it's just a couple images, here's a site that supposedly does it for free.
OCR Terminal http://www.ocrterminal.com has been the best (most accurate) free tool out of at least a dozen that I have used. It works especially well with formatted (table) data.

Finding audio peaks in video files

I have a bunch of video files that I want to process. I want to write a program that can find the audio peaks in each file and return the times where those peaks occurred.
I've looked for a lot of different APIs in different languages but couldn't get any of them to work. I am partial to php and java, so if anyone knows any good audio processing libraries in those languages that would be great! But really I don't care too much about the language. I will need to run this program on a cron.
Also, is it possible to use system calls to ffmpeg from within a script to accomplish this? Thanks in advance.
While I've only used this to work directly with audio files, the python wrapper around theechonest's audio analysis service can slurp in the audio from various video files. It uses ffmpegs shared libs to do this, though I find this wrapper much easier to work with via python then the command line.
Of particular interest within the api is echonest.video which is, to quote the docs:
Framework that turns video into silly putty.
I'd add a couple other helpful urls but apparently I can only add one since I don't have a reputation...
anyway, hopefully that's a helpful lead.

SVG to PDF on a shared linux server

I have a website which uses SVG for an interactive client side thingamabob. I would like to provide the option to download a PDF of the finished output. I can pass the final SVG output back to the server, where I want to convert to PDF, then return it to the client for download.
This would need to work on a headless shared linux server, where installation or compilation is either an enormous pain, or impossible. The website is PHP, so the ideal solution would be PHP, or use software that's easily installed on a shared webserver. Python, perl and ruby are available, along with the usual things you might expect on a linux box. Solutions that involve cairo, scripting inkscape, or installation more complex than 'FTP it up' are probably out. Spending large amounts of money are also out, naturally. As this is a shared server, memory and/or CPU hungry solutions are also out, as they will tend to get killed; this more or less rules out Batik.
The nearest that I've got so far is this XSL transform which I can drive from PHP and then squirt the resulting postscript through ps2pdf (which is already installed). The only problem with this is that it doesn't support SVG paths - if it did, it would be perfect.
There are a bunch or related questions on StackOverflow, all of which I've read through, but they all assume that you can either install stuff, spend money, or both.
Does anyone have an off-the-shelf solution to this, or should I just spend some downtime trying to add paths support to that XSL transform?
Thanks,
Dunc
I stumbled across TCPDF today which would have been perfect for this, had I known about it at the time. It's just a collection of pure PHP classes, no external dependencies for most things.
It can build PDF's from scratch and you can include pretty much anything you want in there, including SVG (amongst many, many other things), as shown in these examples:
http://www.tcpdf.org/examples.php
Main project page is here:
http://www.tcpdf.org/
Sourceforge page is here:
http://sourceforge.net/projects/tcpdf/
You can use Apache FOP's free Batik SVG toolkit which has a transcoder api to transform SVG to PDF.
download link
You will need to write a tiny bit of java. There are code examples here – note you will need to set the transcoder to org.apache.fop.svg.PDFTranscoder instead of Java.
You should be able to do this without installing anything on your machine – just drag the jars on there and run a script. I quote:
All other libraries needed by Batik are included in the distribution. As a consequence the Batik archive is quite big, but after you have downloaded it, you will not need anything else.
have you looked at imagemagick? I suspect you also need ghostscript to complete the loop, which might make installation difficulty and performance a problem.
I'd suggest giving princexml a try, they provide various addons (including one for PHP) and can output PDF from SVG/HTML/XML.
i have used TCPDF (http://www.tcpdf.org/) in many projects and it work in almost every use case.
Here is the example of SVG: https://tcpdf.org/examples/example_058/
and following is the code which can help you:
$pdf->ImageSVG($file='images/testsvg.svg', $x=15, $y=30, $w='', $h='', $link='http://www.tcpdf.org', $align='', $palign='', $border=1, $fitonpage=false);
$pdf->ImageSVG($file='images/tux.svg', $x=30, $y=100, $w='', $h=100, $link='', $align='', $palign='', $border=0, $fitonpage=false);

Resources