Hey I'm new to writing bash and would like to make a script that asks a user to enter a pdf file and then converts the pdf to a png file. Is there a simple way to go about doing this? I know to use read command to ask for user input. How would I handle variables and then once the user enters the pdf file location how to change it to a png?
Thanks.
You can use convert command
convert file.pdf file.png
Related
I am trying to open an image in my Rust program. The image is named foo.png, but it won't open the image with image::open("foo.png").
If I rename the file to foo.jpeg, I can open the image, so my guess is that the formatting and the file extension do not match.
My question is then. how do I open a file named foo.png, but decode it as a jpeg?
I have tried image::io::Reader, but I can't seem to make it work properly.
You can use the image::load() function, which lets you specify the format:
let image = image::load(BufReader::new(File::open("foo.png")?), ImageFormat::Jpeg)?;
Currently, I'm trying to move a docx to a mediawiki file and preserve the proper filenames in the [[Image:]] tags. For some reason, the proper image file gets swallowed (ie, normally it'd be media/image4.jpg, but instead it's just empty).
I've tried extracting the docx and looking at docx/word/_rels/document.xml.rels but I have no idea how to figure out what images are duplicated. I made a simple script to do some find/replace, but in one file I have 130 [[Image:]] tags and only 105 images.
As such, I would like to have the MediaWiki filter output the proper image name when doing this:
soffice --headless --convert-to txt:MediaWiki myfile.docx
I'm on ubuntu 14.10.
Is this possible?
This doesn't appear to be possible, but I have written a workaround found here that solves it. The long and short of it is that I convert the file and manage uploading / linking of images manually.
Is there any way to bulk download background images from an image sequence?
Specifically, I'm looking to download the different image sequences from this website: lookbook.reebok.com
I found a solution to it. In terminal, write curl http://asdf.com/what/ever/image/img[00-99].gif -o img#1.gif And change it to your desired URL, number of images and format. If you write a number thats higher than what exists, terminal will create empty files in the format you requested.
I need to create images of the first page of some source code text files, like asp or php or js files for example.
I usually accomplish this by typing a command like
enscript --no-header --pages=1 "${input_file}" -o - | ps2pdf - "${temp_pdf_file}"
convert -quality 100 -density 150x150 -append "${temp_pdf_file}"[0] "${output_file}"
trash "${temp_pdf_file}"
This works nice for my needs, but it obviously outputs an image "as is" with no "eye-candy" features.
I was wondering if there's a way to add syntax highlighting too.
This might come handy to speed up the creation of presentations of developed works for example.
Pygments is a source highlighting library which has PNG, JPEG, GIF and BMP formatters. No intermediate steps:
pygmentize -o jquery.png jquery-1.7.1.js
Edit: adding source code image to the document means you are doing it wrong to begin with. I would suggest LaTeX, Markdown or similar for the whole document and source code document could be generated.
Another easy/lazy way would be to create an html document using pygmentize and copy-paste it to the document. Not professional, but better than raster image.
Here's how I do it on my Mac:
I open up the file with MacVIM. MacVIM supports syntax highlighting.
I print the file to a PDF. This gives me a paged document with highlighted syntax.
When I print, The program Preview opens up to display the file. I can Export it to a jpg, or whatever my hearts desire.
I don't have a Mac
This works with Windows too.
You have to get VIM although Notepad++ may also work. Any program editor will support syntax highlighting and allow you to print out with the highlighted syntax. So, pick what you like.
You have to get some sort of PDF producing print driver such as CutePDF.
Converting it to a jpg. I think Adobe Acrobat may be able to export a PDF into a JPG, or maybe the print driver can print to a JPG instead of a PDF. Or, you can send it to a friend who has a Mac.
i need to convert rtf document that contains images (jpgs/pngs ) to image format
jpgs or pngs programmaticly , do you have any ideas on how to do it ?
on server side (web)
Thanks
You can use a virtual printing device, for example: http://www.joyprinter.com/
If by programmatically, you mean scripts, you could script your RTF program to open files, then export to PDF, then export the PDF to an image. At least, this kind of operation is relatively easy on OS X. You could probably do it entirely in Automator, using TextEdit and Preview. Otherwise, on OS X you could also try accessing the core services that would do the same thing. No clue on Windows though. Hope that helps!
You might want to write a bash script to be executed by a cronjob. So at a defined time, or after a defined period, you will have your rtf files converted into jpgs.
Though I don't know if this might satisfy your "programmatic" need .. here is how to do this conversion:
To convert rtf files contain "advanced" features like images, as in your case, you need unoconv, which requires libreoffice to be installed.
unoconv -f pdf "${input_file}"
Otherwise, just for reference because it's not your case, if the rtf files contain only simply text you can avoid the requirement to have libreoffice installed by using a cascade conversion like
// convert rtf to txt
unrtf --text "input_file.rtf" > "temp.txt"
// convert txt to pdf
enscript "temp.txt" -o - | ps2pdf - "temp.pdf"
// convert pdf to jpg
convert -quality 100 -append "temp.pdf" "output.jpg"
// remove temp files
trash "temp.txt" "temp.pdf" // or rm if you prefer