Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import * as path from "path";
- import * as fs from "fs";
- import * as sizeOf from "image-size";
- import * as sharp from "sharp";
- let imagePath = path.win32.normalize(process.argv[2].split("'")[1]);
- //process.chdir(imagePath);
- //var dimensions = sizeOf.default("");
- //console.log(dimensions.height > dimensions.width);
- // $ node test.js "C:\Users\dan"
- // ==> C:\Users\dan\Pictures\ss\
- let input = "h.jpg";
- sharp
- .default(input)
- .resize(2000, 1200, {
- fit: "outside",
- })
- .toFile("output-outside-h-2000-1200.jpg");
- input = "w.jpg";
- sharp
- .default(input)
- .resize(2000, 1200, {
- fit: "outside",
- })
- .toFile("output-outside-w-2000-1200.jpg");
- input = "w.jpg";
- sharp
- .default(input)
- .resize(1200, 2000, {
- fit: "outside",
- })
- .toFile("output-outside-w-1200-2000.jpg");
- input = "h.jpg";
- sharp
- .default(input)
- .resize(1200, 2000, {
- fit: "outside",
- })
- .toFile("output-outside-h-1200-2000.jpg");
- input = "w.jpg";
- sharp
- .default(input)
- .resize(1200, 2000, {
- fit: "inside",
- })
- .toFile("output-inside-w-1200-2000.jpg");
- input = "h.jpg";
- sharp
- .default(input)
- .resize(1200, 2000, {
- fit: "inside",
- })
- .toFile("output-inside-h-1200-2000.jpg");
- input = "h.jpg";
- sharp
- .default(input)
- .resize(2000, 1200, {
- fit: "inside",
- })
- .toFile("output-inside-h-2000-1200.jpg");
- input = "w.jpg";
- sharp
- .default(input)
- .resize(2000, 1200, {
- fit: "inside",
- })
- .toFile("output-inside-w-2000-1200.jpg");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement