Automation Techs For Productivity And Fun

Showing posts with label image processing. Show all posts
Showing posts with label image processing. Show all posts

Check And Remove EXIF Including GPS Data Contained In JPEG Files With Node.js


Exif is information data set to an image file when you take photos with cameras.
GPS data like latitude and longitude are often included in Exif data, so you have to be careful when uploading photos you took to public spaces on the Internet.

Popular photo sharing services like Instagram automatically remove GPS data when photos are uploaded, but if you're not sure how GPS data are treated on other services, you may want to check and remove Exif data by yourself before uploading.

There are many tools to check and edit Exif data, like ExifTool. And for programmers, most popular programming languages have some kind of libraries to treat Exif data.

For Javascript, Piexifjs would by easy to use. It works both for web client-side and Node.js.

Here is a sample script to show Exif data of JPEG images:


And Here is a sample to remove Exif data from JPEG images:

Share:

Bulk Resize Image Files Using OpenCV And Node.js


Installing OpenCV requires lot of work and disk space, so I know I should use other libraries like gm with GraphicsMagick or Jimp when I want to resize images with Node.js. Though I've already have OpenCV and opencv4nodejs installed, so I'll just write about resizing images using OpenCV.

"opencv4nodejs" is a wrapper package of OpenCV for Node.js. By using this package, you can call image processing functions included in OpenCV.

There are two functions for image resizing: "resize" and "resizeToMax". "resize" is for resizing or scaling image to specified size, and "resizeToMax" is for resizing image to height and width that fits specified max length keeping aspect ratio.

This time I wanted a script to bulk resize images in directory to fit in same size, so I used "resizeToMax".

Here's the script:


It resizes all jpeg images in SOURCE_DIRECTORY_PATH to fit 100 x 100 and saves it to DEST_DIRECTORY_PATH with same file name.

Share:

How To Convert Photo Images To Fantastic Line-Drawings With Node.js


Last day I wrote an article about converting images to line-drawings using Python and OpenCV.

https://blog.pyrospect.com/2019/01/how-to-convert-photo-images-to.html

I like Python as a programming language and I believe OpenCV matches best with Python, though the main language for my personal projects is Javascript, I was looking for a way to do the same thing using Javascript and Node.js.

First I've tried OpenCV.js, the officially supported Javascript bindings for OpenCV,
but somehow it didn't work on my machine.

https://docs.opencv.org/3.4.5/d5/d10/tutorial_js_root.html

I found other image processing libraries not using OpenCV, and they looked useful for other purposes, but for the purpose this time, it seemed using OpenCV is the best.

https://github.com/oliver-moran/jimp

https://github.com/lovell/sharp

http://aheckmann.github.io/gm/

I finally chose "opencv4nodejs", a Node.js module that works as Javascript binding for OpenCV alternative. And this worked perfectly well.

https://www.npmjs.com/package/opencv4nodejs

This library provides OpenCV functions as Javascript functions with more Object Oriented style to make it easy to use in Javascript programs.

Here is the source code for Node.js, which I rewrote from my Python program in the article above:

The "opencv4nodejs" module downloads OpenCV when installing from NPM, so you don't have to install Python and OpenCV.

npm install --save opencv4nodejs

Share:

How To Convert Photo Images To Fantastic Line-Drawings Using Python And OpenCV

I've received a request for advanced coloring books from my daughter, who entered elementary school last year, but I couldn't find those kind of coloring books in book stores nearby. So I've wrote a program to create line drawings from photos.

The program works like this.

Before

After

Source Code

I chose Python and OpenCV for image converting functions.

Install Python3 for your OS, and install OpenCV from pip.

pip install opencv-python

This is the script I wrote.
It reads ".JPG" files in source directory and outputs converted files to destination directory.


Gallery

Here are some images I've made.

Amusement Park
Food Stands
Park
Girl Watch Ducks

Share:

Search This Blog

Labels

Generate Data For Testing With PostgreSQL

When developing a software using PostgreSQL database as storage, the function "generated_series" is very useful to create data ...

Powered by Blogger.

Labels

Recent Posts