Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
tiff-to-png
Advanced tools
A batch converter for multipage tiff files to png (or any imagemagick supported type).
A batch converter for multi page TIFF files to png or any other format you have support for within your installation of imagemagick.
This module was created to solve the problem of passing 100+ multi page TIFFs into a converter.
TIFF to PNG allows you to pass an array of paths of TIFF files (strings). It will then iterate through the array and convert each TIFF one at a time (synchronously).
Each TIFF is split and placed in a folder with the same name as the original file without the extension. Once complete the location you supply will have a list of folders with image files inside in the format you requested. This is best suited for multipage TIFFs as the pages will be split and have a png file each.
Install "tiff-to-png" using npm, append "--save" to save it in your package.json
$ npm install tiff-to-png
TIFF to PNG requires instantiating to get access to it's features.
var ConvertTiff = require('tiff-to-png');
var options = {
logLevel: 1
};
var converter = new ConvertTiff(options);
var tiffs = [
'/home/tiffs/document_one.tif',
'/home/tiffs/document_two.tif'
];
var location = '/srv/www/mysite/public/documents';
converter.convertArray(tiffs, location);
In the above example I am passing in 2 TIFF files to convert and place in the folder '/srv/www/mysite/public/documents'.
The full options object is as follows:
{
type: 'jpg',
logLevel: 1,
prefix: 'page',
suffix: '_foo',
tmpPath: '/path/to/tmp',
autoRemoveTmp: true
}
Option | Default | Description |
---|---|---|
type | 'png' | The file type of the converted files |
logLevel | 0 | The level of the logs required. 0: Errors only, 1: Information |
prefix | 'page' | The string that will be prepended to the file names of the pages converted. E.g. 'page': page1.png |
suffix | '' | The string that will be appended onto the end of the file names of the page converted. E.g. '_invoices': page1_invoices.png |
tmpPath | null | Overwrites the Imagemagick default tmp directory path |
autoRemoveTmp | false | Automatically removes all files from tmpPath prefixed with magick-*, this happens on process completion |
There are 2 available callbacks to allow you to create actions on the success of individual conversions and when the queue is complete.
The progress callback is called every time a conversion has finished whether there was an error or not.
var ConvertTiff = require('tiff-to-png'),
converter = new ConvertTiff();
// Setup Callback
converter.progress = function(converted, total){
// Do something with converted and/or total
};
var tiffs = [
'/home/tiffs/document_one.tif',
'/home/tiffs/document_two.tif'
];
var location = '/srv/www/mysite/public/documents';
converter.convertArray(tiffs, location);
Argument | Description |
---|---|
converted | An array of objects that contain the original path, the target path and whether the conversion is a success or not. |
total | The total number of requested conversions |
The complete callback will be called when the conversion of the final TIFF has finished.
var ConvertTiff = require('tiff-to-png'),
converter = new ConvertTiff();
// Setup Callback
converter.complete = function(errors, total){
// Do something with errors and/or total
};
var tiffs = [
'/home/tiffs/document_one.tif',
'/home/tiffs/document_two.tif'
];
var location = '/srv/www/mysite/public/documents';
converter.convertArray(tiffs, location);
Argument | Description |
---|---|
errors | An array of strings with the error returned by Imagemagick on fail |
converted | The 'converted' argument is an array of objects that contain the original path, the target path and whether the conversion is a success or not. |
total | The total number of requested conversions |
Some variables that are accessible off the Tiff to PNG instance.
Variable | Description |
---|---|
converted | An array of objects that contain the original path, the target path and whether the conversion is a success or not. |
total | The total number of requested conversions |
location | The location that the converted file will be stored |
tiffs | The list of TIFFs passed to convertArray |
options | The options passed during instantiation |
errors | An |
var ConvertTiff = require('tiff-to-png'),
converter = new ConvertTiff();
var tiffs = [
'/home/tiffs/document_one.tif',
'/home/tiffs/document_two.tif'
];
var location = '/srv/www/mysite/public/documents';
converter.convertArray(tiffs, location);
console.log('Started converting %i TIFFs', converter.total);
The logging has a similar appearce to mocha tests and will allow you to see the outcome of the conversion live from the comfort of your terminal window.
If an error occurs during the conversion of a TIFF file the error will be logged, stored in the converted array and the error array. The queue will then continue to convert.
TIFF to PNG requires imagemagick to convert TIFFs to any format.
npm test
This module was originally written to be used in a production environment. This will ensure that this module is well maintained, bug free and as up to date as possible.
I will continue to make updates as often as required to have a consistently bug free platform, but I am happy to review any feature requests or issues and am accepting constructive pull requests.
FAQs
A batch converter for multipage tiff files to png (or any imagemagick supported type).
The npm package tiff-to-png receives a total of 92 weekly downloads. As such, tiff-to-png popularity was classified as not popular.
We found that tiff-to-png demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.