Showing posts with label HowTos. Show all posts
Showing posts with label HowTos. Show all posts

Tuesday, April 12, 2022

Convert images in batch using free tools then make PDF from them.

I was trying to collect public domain PDFs published by Gita Press Gorakhpur from archive.org but the sizes of pdfs are huge. They are unnecessarily high in size. Instead of pdf I downloaded JP2 files and batch converted them to jpg in lower quality setting without loosing any readability. Using this saved me huge space. If published PDF was of 2GB mine was <100MB and perfectly readable.


Above was an example to convert images in batch using free tools. Below are steps to do the same.


- Download ImageMagick-7.1.0-29-Q16-x64-static.exe from https://imagemagick.org/script/download.php

- Install it and try to run magick.exe from cmd.exe. cmd can be run from search box in windows 10.

- Put all images in some folder for example IMAGES. Open cmd.exe and change directory to the IMAGES folder. To do this copy address of this folder from file properties or address bar of windows file explorer. Go to cmd and type cd CTRL+V. Now type drive letter with colon. Example cd D:\folder1\folder2\IMAGES and then D:. This will move us inside the IMAGES folder.

- Type dir command and it should list all images. This shows we are inside the IMAGES folder.


Commands to convert images. Suppose images are jp2 files downloaded from archive.org and we want to convert them to jpg format inside JPG folder in IMAGES. Create JPG folder and run below command.


magick.exe mogrify -path JPG -quality 25% -resize 1500x1500 -format jpg *.jp2


quality option can be removed if not required. I needed it to reduce jpg size. Now it will take time and convert images to jpg format in JPG folder. Now convert these all JPGs to PDF with this command. Change directory to JPG folder using command cd JPG.


magick convert *.jpg -quality 25% 1.pdf


quality option can be removed. I just kept it in case various size PDF are to be tested.


To automate the process make a text file batch_convert.bat and paste below text into it.


mkdir jpg

magick.exe mogrify -path jpg -quality 25% -resize 1500x1500 -format jpg *.jp2

cd jpg

magick.exe convert *.jpg 1.pdf


Copy this file into folder which contains all jp2 files. Run this file double clicking it. When everything works fine it creates a PDF file 1.pdf. All jp2 and jpg files can be deleted later if not needed. To change quality of pdf -quality % value in bat file can be increased. If not sure just use 90%. Its default in most of JPG files.


Instead of using image magick we can also use Fast Stone Image viewer from https://www.faststone.org/FSView.erDetail.htm. This is really good image viewer and has batch conversion, rename tools. Go to Tools - Batch convert images to convert images in batch if you don't like ImageMagick. However ImageMagick is fast and has lots of options and works on Linux, Mac, Android etc. Learning to work with it will make you familiar with multiple OSes.



Monday, July 29, 2019

How to attach binocular tripod adapter on Olympus DPS I 10x50?

Olympus DPS I 10x50 is great binocular for multiple purposes including Astronomy. However its heavy and requires tripod to stay focused to object. It takes help to find how to attach it to a tripod. Following points show how to do it

  • There is a circular removable cover in front of binocular. It has Olympus written on it. Look at side of bigger lenses that is objective lens region.
  • Take help from images below.
  • Rotate the disk anti clockwise to open it. It will open and expose a metallic nut where bolt of adapter will fit.
  • Assemble the adaptor to this and binocular is ready for tripod mount.

At center there is cover with Olympus written.




Nut exposed. Fit the bolt of adapter here.




Adapter is fit on binocular.



Amazon Basics tripod with Datyson 5P0031 adaptor.




Sample output image captured using Nokia 8.1.
Setup =>
Amazon Basics Tripod
Olympus Dps I 10x50 binocular
Datyson 5P0031 adapter




Below are links to some products -



Saturday, April 6, 2019

Fix Windows 10 freeze of switching to fullscreen on PCSX2 (and other apps)

While using PCSX2 whenever i switched between windowed and fullscreen sometimes windows got freeze and will never respond to whatever keys i press. Had to shutdown laptop using power button. I found this problem is windows problem and faced by many users in various apps. Below is the fixed that worked for me -

Go to Windows 10 Settings -> Gaming

Disable Game Bar fully and now this problem may not occur. If possible disable most of game settings and use only those which don't cause freeze issue. I have disabled all of them as i can use AMD relive to record PC screen. This fixed free on my AMD (A10-9600P APU) laptop

Monday, July 16, 2012

pstops tutorial (psutils)

I have recently started to port my game engine GGE to HTML5. So i downloaded javascript & HTML5 tutorials (PDFs) from http://www.tutorialspoint.com/.


But now a days i only keep pocket references for technologies i use instead of heavy books. So i wanted to make a pocket version of those PDFs. I found "pstops" after google'ing, in just an hour i was irritated by the mangled parameters it needed and badly documented manpages & stuffs on internet.


But these two pages made my concept clear and i achieved my task in few minutes.


[REF1] Read this first:
http://wiki.scribus.net/canvas/How_to_make_impositions_with_pstops

[REF2] Then ( this will make you clear about what exactly pstops does):
http://code.google.com/p/uwisdom/wiki/Pstops

My own description ( i assume you have read REF1):
pstops => postscript to postscript converter with desired arrangements, page layouts and sizes.

I will describe this powerful utility by small implementation because that in run accomplishes many people's job.

For experiments please get a ps file of atleast 16 pages. You can convert a PDF into ps by using pdftops utility (its a part of psutils). I am using 23 page file. Lets do some ps conversions.


1. Flip all the pages vertically Or horizontally
vertically:
pstops '1:0V' in.ps out.ps 



Horizontally:
pstops '1:0H' in.ps out.ps 



Description:
As you can see the parameters of pstops are:

pstops  [ -q ] [ -b ] [ -wwidth ] [ -hheight ] [ -ppaper ] [ -dlwidth ] pagespecs [ infile [ outfile ] ]


Most of us have difficulty in pagespecs parameter only. Which is described below:

pagespecs   = [modulo:]specs
specs          = spec[+specs][,specs]
spec            = [-]pageno[L][R][U][H][V][@scale][(xoff,yoff)]

In our flip example, we used '1:0H', What are these hex like codes? lets dissect -
1 => it tells that we want  to print 1 page of "in.ps" in 1 page of out.ps (A4 by default).
If we want to print 4 pages in 1 A4 page we have to use '4:0', for 8 we use '8:0'

:0  
: sign is followed by SPECS. But we have nothing after 0. It simply means that we want to use original unchanged source pages in output file. With -0 end becomes start and start becomes end page. i.e. page numbers get inverted.

2. Lets print two pages in one side, i.e. total 4 in 1 output page. Portrait mode 
pstops '4:0' in.ps out.ps
output => [1] [2] [3] [4] [5] [6] Wrote 6 pages, 1250990 bytes

We get 6 pages in output. But, upon seeing out.ps why we get only 6 pages printed from source instead of all pages? The answer is simple: Did we specified how and where the pages had to be printed? we told to print 0 only i.e. 1st page ( 0 index => 0+1 page number ) of every block.

You don't know what block is? Please refer to REF1 above. In brief i also write here:
Blocks = total pages in input file / total pages we want in our 1 page of output file

1 block simply means number of input pages we want to be printed in 1 output page, above we told to print only 0th index Or 1st page of every block. That is why only 1st pages were printed.

Below is the proper command to print all pages.
pstops '4:0@0.5(0.0w,0.5h)+2@0.5(0.0w,0.0h),1@0.5(0.0w,0.5h)+3@0.5(0.0w,0.0h)' in.ps out.ps

It will output 2 portrait pages per side. Lets understand all the parameters:
4: => 4 input pages / 1 output page

0@0.5(0.0w,0.5h) 
0 => 0th index of block i.e. 1st page
(0.0w,0.5h) => move right by 0% of page width. 50% of height. AFAIK the w,h are of source page.
@0.5 => scale to become 50% of original size.

+2@0.5(0.0w,0.0h)
+ => continuing page on 1st side.
2 => 2nd index of block i.e. 3rd page
(0.0w,0.0h) => no movement, just remain at output's Origin i.e. left-bottom. Just like Cartesian coordinates.
@0.5 => scale to become 50% of original size.

NOTE:
1. x,y are offsets, this is what i have understood, they are not exact render start points. Therefore you should have noticed to draw from top we just have to go 0.5h ( half of output page height instead of full height). 

2. I have not used rotations. You should keep in mind that after rotation the origin of that rotated page still remains at its own left-bottom. So the whole output will change after using rotations. Try it:

pstops '4:0L@0.5(0.0w,0.5h)+2L@0.5(0.0w,0.0h),1L@0.5(0.0w,0.5h)+3L@0.5(0.0w,0.0h)' in.ps out.ps

It outputs blank pages! You know why?
Because when we rotated left (imagine you are holding the paper at left-bottom and rotated it left. Then it goes outside of the output page boundaries. For that you have to translate all pages by full width.

so try this now:

pstops '4:0L@0.5(0.75w,0.5h)+2L@0.5(0.75w,0.0h),1L@0.5(0.75w,0.5h)+3L@0.5(0.75w,0.0h)' in.ps out.ps

in parameters we have described that 1st side of output page will follow this specification:
pages: 1, 3
0L@0.5(0.75w,0.5h)+2L@0.5(0.75w,0.0h)
and the second back side will follow this: ( separated by comma )
pages: 2, 4
1L@0.5(0.75w,0.5h)+3L@0.5(0.75w,0.0h)

Then all the coming blocks will follow these specifications.


For more details below is a simple illustration: please neglect the quality, i made it quickly to illustrate rather than writing 100 lines. :-)
























hope this tutorial will help you to understand how to utilize the power of pstops without Hit n Trials method :-p. Please let me know if you find some bugs or wrong info (if really it is).


Search TAGs:
linux 4-up, make 8 page booklet, linux pstops tutorial, pstops concept, how pstops works, make mini booklets, 8 page booklets 

Tuesday, December 27, 2011

Use android device to connect to internet on PC using USB cable or any wireless source.

I was new to android, and wanted to connect to internet via GPRS/EDGE/3G connections. But unfortunately I couldn't find any modem support in android. In run of demand for a DUN connection I found tethering option in Android phone and found connecting to PC for internet via Android is dead easy!, thanks to tethering, below are the steps and references:-


My devices and setup:
Android version: v2.2, Froyo
Device: ZTE Blade (Or Dell XCD35, Idea Blade in India)
PC: Toshiba Satellite C650 AMD Athlon II P320 CPU, HD4200 ATI card
OS: Windows XP

STEPS:
1. Enable Internet on your Android phone via any source you have access to like GPRS/EDGE/3G data plans.
2. Connect the phone to your Laptop/desktop using USB cable (Otherwise below option will be disabled)
3. Go to phone settings and enable USB tethering :-

Press Home -> press menu -> wireless & networks -> Tethering & portable hotspot -> USB Tethering
Enable this check button.


Once enabled,  If your pc drivers are installed correctly, you will see HSUSB device connected message, remote NDIS adapter device will be shown on your device manager.


Verify the correct setup:
1. Check if your Android device shows BLUE USB icon on the taskbar which opens tethering upon touch event.
2. Open Device manager in windows XP or other OS. Network adapters should show

"Remote NDIS based internet sharing device"


My details are:
Manufacturer: ZTE Corporation
Location: Location 0 (ZTE HSUSB Device)
Control panel => Network Connections => Remote NDIS based internet sharing device




 4. Test internet on your phone if it works, then for sure you will get same speed in your PC.



You can test the speed of your internet by simple command. Open cmd.exe from run dialog and type

ping google.com

below is output from my console:

Pinging google.com [74.125.113.104] with 32 bytes of data:


Reply from 74.125.113.104: bytes=32 time=516ms TTL=45
Reply from 74.125.113.104: bytes=32 time=517ms TTL=45
Reply from 74.125.113.104: bytes=32 time=513ms TTL=45
Reply from 74.125.113.104: bytes=32 time=515ms TTL=45



The lower your time is the faster your internet connection will be. EDGE normally shows values between 200 to 700. Values above it are very slow connection. I get ~250 average in low traffic, ~20-30KBps.




CONCLUSION:
Android's USB tethering just means to share internet from your device to other device no matter what the source of your internet is. So we don't need any kind of Dial Up networking support in phones. So this is a universal solution and that's why android don't need DUN :-).




References:
Tethering & Hotspot
http://support.google.com/mobile/bin/answer.py?hl=en&answer=182134


Share your mobile data connection:
http://support.google.com/mobile/bin/answer.py?hl=en&answer=168932


Windows XP's Android RNDIS device information, tethering, INF file
http://www.android.com/drivers/tetherxp.inf



ZTE Blade drivers:
http://www.zte.co.jp/products/handsets/handsets_gallery/softbank/info/201012/P020101217594818380622.zip

ftp://ca:welcome@ftp.brightpointuk.co.uk/Technical%20Support/ZTE/ZTE_Handset_USB_Driver.exe


Plugging Android phone to PC shows a CDROM with their drivers which upon enabling SDCARD gets removed.



EXTRA (part of my marketing):

If above steps have solved your problem and you are happy, and you do not hate games :), please try the games I have developed.


DesiBallGame - My first android game, recently released

https://play.google.com/store/apps/details?id=org.greh.desiballgame


 My PlayStore profile:

https://play.google.com/store/apps/developer?id=GamesGreh


My website for games:

http://www.gamesgreh.in

Sunday, December 16, 2007