Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Script to resize JPEG files  (Read 11402 times)

0 Members and 1 Guest are viewing this topic.

Geek-9pm

    Topic Starter

    Mastermind
  • Geek After Dark
  • Thanked: 1026
    • Gekk9pm bnlog
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
Script to resize JPEG files
« on: December 30, 2017, 04:45:21 PM »
A rekative left me a PC with a ton of JPEG fiels on it. I agreen to save some of the files and put them on a DVS and I get the PC free.

I had no  idea.  ::)

Have can anybvody acumulate over 200 GB of JPEG photos in seven years?

The fits thing I need to do is reduce the size of the images. I mean the number pixels. thes are someting absurd like 4500  wide and 2600 high. I need to reduce these to a sane size, maybe 1200 x 800.

I have a photo editor, but I do not remembert how to automati it.
So I am asking, is there some kind of simple utility the will do a  hugwe directoryu and redcue the size of a JPEG in the directlry?

Thnask for your help.

Salmon Trout

  • Guest
Re: Script to resize JPEG files
« Reply #1 on: December 30, 2017, 05:24:58 PM »
Image Magick (spelled thus). Eminently scriptable. But- why don't you just take out the hard drive and put in a USB enclosure and present it to them? Or refuse the deal. I would. The time to burn 50+ DVDs? To get some old PC? Come on! Also, that "sane size" reduction might be vandalism.


Geek-9pm

    Topic Starter

    Mastermind
  • Geek After Dark
  • Thanked: 1026
    • Gekk9pm bnlog
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
Re: Script to resize JPEG files
« Reply #2 on: December 30, 2017, 06:12:13 PM »
Salmon Trout,
Thank you, you ideas are right on.
But she is a relative and we have a warm relationship and it would be a bad move to refuse here gift. My fault. I offered to save hee photos.
I am not goin to do 40 DVDs.
I think I will but it down to two or three and make it a slide show she can play on amy Dvd player. Most of what she really wants a re the pictures of here adported boy growing up. Pitures of other famiklies are less relevant.

Yes, I will have to do a lot of hand picking, but first I hve to get the size down. My trusty rusty photo editr chokes ion these directories while making thumbnails is preview mode.

After doing a XCOPY to anothe drive, it looks like maybe 8,000 files and every one is over 2 bega bytes There were some MOV files that took up some space. I am going to concentrate on the JPEG.

The MOV files have the wrong ration. That is a problem I might deal with later. Or maybe not.

Thanks for you suggestion.
I found this as the place to get Image Magick.
https://www.imagemagick.org/script/index.php
Quote
The functionality of ImageMagick is typically utilized from the command-line or you can use the features from programs written in your favorite language.
Looks like what I want.  :)

BC_Programmer


    Mastermind
  • Typing is no substitute for thinking.
  • Thanked: 1140
    • Yes
    • Yes
    • BC-Programming.com
  • Certifications: List
  • Computer: Specs
  • Experience: Beginner
  • OS: Windows 11
Re: Script to resize JPEG files
« Reply #3 on: December 30, 2017, 07:56:19 PM »
Personally, I think that if you agreed to save the files, you should either do it properly, or give it back and say that the scope of the problem is beyond your expectations.

Those "absurd" sizes are completely normal for photographs.

If somebody offered you their house, with the only caveat being you had to move a few paintings into storage, would it make sense to reduce their large paintings to a "reasonable size" by snapping them into quarters?


Resizing jpeg photographs as excessively as you've got in mind is pretty much the same level of destruction. They asked you to save the images to begin with they obviously value them. The fact that you do not and want to make it easier to get a free computer isn't relevant, even if you are likely to get away with it.

I was trying to dereference Null Pointers before it was cool.

DaveLembke



    Sage
  • Thanked: 662
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
Re: Script to resize JPEG files
« Reply #4 on: December 30, 2017, 08:37:19 PM »
In this situation, I would either provide or have them provide a external hard drive. 500GB or smaller externals are cheap these days. Then run a batch file that will find all JPG files and copy them to the external drive. This way its easy and they have all files as they are without alteration.

Something like this assuming the external drive is at E:

Code: [Select]
c:
cd\.
xcopy *.jpg e:\jpg\*.* /s/y/h






Mark.



    Adviser
  • Forum Regular
  • Thanked: 67
    • Yes
  • Certifications: List
  • Computer: Specs
  • Experience: Experienced
  • OS: Windows 10
Re: Script to resize JPEG files
« Reply #5 on: December 30, 2017, 10:29:27 PM »
I'm pretty much in agreement with the others Geek.

you can either put their drive into an enclosure and give it back as is, they can then decide what photos need to be copied off it.
this method then allows you to upgrade the old PC with either a new HDD or get a SSD.

or as stated, get them to provide you with an external drive, knowing the average user, they haven't got one now, so this would be used to copy their pics onto then down the track be their backup drive.

Geek-9pm

    Topic Starter

    Mastermind
  • Geek After Dark
  • Thanked: 1026
    • Gekk9pm bnlog
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
Re: Script to resize JPEG files
« Reply #6 on: December 31, 2017, 01:12:01 AM »
OK, I have the files now on nother drive in the same format and size. These are JPEG fioes taht where save in a huge format. The photos are tabout 2 to 7 megabytes each. How big a TV does it take to show a photo that is over 5000 pixels wide?  Do they make them that big?

An SSD drive might be out of the question.  But maybe I could use two or three USB flash drive.

Or maybe I souhd get a 500 GB hard drive and put it in an enclosure. That  would take much less time for sure.

EDITl: Hey, I just found out that flash drives and now super cheap. When did that happen? All the fiels would fit inside of a $10 250 GB flash drive. So I could just put them on a flash drive and give it to here. Do new TV sets now do slide shows of JPEG photos? I think I saw taht soemewhere. That would be the best way to see all the old photos.  :o

« Last Edit: December 31, 2017, 01:38:24 AM by Geek-9pm »

BC_Programmer


    Mastermind
  • Typing is no substitute for thinking.
  • Thanked: 1140
    • Yes
    • Yes
    • BC-Programming.com
  • Certifications: List
  • Computer: Specs
  • Experience: Beginner
  • OS: Windows 11
Re: Script to resize JPEG files
« Reply #7 on: December 31, 2017, 01:44:31 AM »
Quote
OK, I have the files now on nother drive in the same format and size. These are JPEG fioes taht where save in a huge format. The photos are tabout 2 to 7 megabytes each. How big a TV does it take to show a photo that is over 5000 pixels wide?  Do they make them that big?

They are standard 11.7Megapixel photographs. They are "huge" because one may want to do all sorts of "photo" things with the picture. Older technologies were much lower resolution which significantly limited what you could actually do with digital photographs compared to film photographs. 11.7Megapixels are a good size for about 8" to 10" prints, for example.
I was trying to dereference Null Pointers before it was cool.

Salmon Trout

  • Guest
Re: Script to resize JPEG files
« Reply #8 on: December 31, 2017, 06:06:53 AM »
So I could just put them on a flash drive and give it to here. Do new TV sets now do slide shows of JPEG photos? I think I saw taht soemewhere. That would be the best way to see all the old photos.
It may depend on the TV. I have 19 GB of images, in folders, on a pen drive. My 5 year old (2012) Samsung smart TV has 2 USB ports. If you put the pen drive in one of them you can use the TV remote control to browse the folders, seeing thumbnails, and select a picture and then zoom & scroll it if you want, and use the arrow buttons to go to previous/next etc.


camerongray



    Expert
  • Thanked: 306
    • Yes
    • Cameron Gray - The Random Rambings of a Computer Geek
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Mac OS
Re: Script to resize JPEG files
« Reply #9 on: December 31, 2017, 08:23:49 AM »
Be careful with mega cheap flash drives, 250gb for $10 doesn't sound right and is almost certainly fake.  There are unscrupulous sellers that buy smaller flash drives and modify the firmware so that they report a higher size, they will appear to work fine until you reach the limit of the physical drive, it will then start to overwrite and corrupt files, something you really don't want to do with this person's photos!

For that amount of photos, pick up a reasonably sized external hard drive from a reputable source and brand, at that size, a hard drive will work out cheaper than a flash drive.  Alternatively, why not just buy an enclosure for the drive that's currently in the PC, put the drive into that and give her her own hard drive back with all her data on it?

strollin



    Adviser
  • Thanked: 84
    • Yes
  • Certifications: List
  • Computer: Specs
  • Experience: Guru
  • OS: Windows 10
Re: Script to resize JPEG files
« Reply #10 on: December 31, 2017, 09:39:14 AM »
I agree with camerongray, a 250GB flash drive for $10 sounds like a scam.  There have been cases where such a drive will be reported by the OS to be a certain capacity but will only accept a fraction of that much data.  The unscrupulous people alter the FAT on the drive so that it reports to be much larger than it really is.  I would expect to pay $50+ for that size thumb drive.  IMO, you could probably pick up a 1TB external HDD for around the same price as a 250GB thumb drive.

Geek-9pm

    Topic Starter

    Mastermind
  • Geek After Dark
  • Thanked: 1026
    • Gekk9pm bnlog
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
Re: Script to resize JPEG files
« Reply #11 on: December 31, 2017, 10:44:33 PM »
BC said:
Quote
They are standard 11.7Megapixel photographs.

You are right. She was using a professional camera and the thing has a very high resolution. Sp I should not try to reduce the number of pixels. In fact, I did a test run and notice  the output files lost the recording date and the name of the camera she used. So I will give up on the idea of reducing the file size.




Geek-9pm

    Topic Starter

    Mastermind
  • Geek After Dark
  • Thanked: 1026
    • Gekk9pm bnlog
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
Re: Script to resize JPEG files
« Reply #12 on: December 31, 2017, 10:47:32 PM »
Be careful with mega cheap flash drives, 250gb for $10 doesn't sound right and is almost certainly fake.  There are unscrupulous sellers that buy smaller flash drives and modify the firmware so that they report a higher size, they will appear to work fine until you reach the limit of the physical drive, it will then start to overwrite and corrupt files, something you really don't want to do with this person's photos!
...
Yeah, I know. But I am am weak and can not resist a bargain.  :-[ And they claim I have a 30 day tune frame to return the device if I find it is not good.    :-\

DaveLembke



    Sage
  • Thanked: 662
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
Re: Script to resize JPEG files
« Reply #13 on: December 31, 2017, 11:51:58 PM »
Cheapest & Safest Storage for 200GB of data would be to use a hard drive like this one, but you would need to install it into a external USB case or install it internally as a extra drive in their current computer for them to have access to their 200GB of pictures.

250GB HDD with 1 year warranty for $13.99
https://www.newegg.com/Product/Product.aspx?Item=9SIA5AD3KE4382

I have bought these low cost drives from newegg in the past for projects, and I like the low cost and warranty that comes with them. Out of the 8 drives I have bought on the cheap through them, no problems yet.

If needing to install it into an external enclosure though such as with this... https://www.newegg.com/Product/Product.aspx?Item=9SIAE786P92705&cm_re=3.5%22_HDD_case-_-9SIAE786P92705-_-Product

Then your at 1/2 the cost of a 1TB external drive in which the new 1TB drive makes more sense vs making your own at 1/2 the cost and 1/4 the capacity.

If they wouldnt mind an additional hard drive installed into a desktop computer assuming it has room for a second hard drive though, then this is the most cost effective solution at $13.99 for just the 250GB drive alone.

A free solution of getting them the images would be if they loaned you their current computer and you transferred the images to the new PC. The newer computer likely has plenty of storage unless they have a Chromebook or something like that with not enough storage capacity such as only a 32GB SSD drive for OS & Storage etc.


Salmon Trout

  • Guest
Re: Script to resize JPEG files
« Reply #14 on: January 01, 2018, 03:00:31 AM »
Quote from: Geek=9PM
Quote from: BC
They are standard 11.7Megapixel photographs.
You are right. She was using a professional camera and the thing has a very high resolution.

Some possible confusion here, methinks.

Consumer-level "point and shoot" cameras are up to about 20 megapixels these days, but they manage to store a reasonable number of images on consumer-size flash cards by using heroic levels of JPEG compression. *censored*, my Motorola Moto G phone has a 13 megapixel camera. Bigger numbers hypnotize the public. My Sony W830 point-and-shoot takes 5152 x 3864 pixel photos at highest quality settings. Each one takes up between 5 and 8 megabytes. You might think "W00T! 20 megapixels! I can zoom in and count every leaf on that bush 100 yards away in the top right corner", but you can't because it has gone to JPEG mush. Such pictures are OK for posting on social media or showing baby to Grandma, but not much good for professional editing and publication. In my "Pictures" folder I have 9,995 such JPG images taking up 19 GB.

Professional and "pro-sumer" cameras can store the original unprocessed (or minimally so) pixel data straight off the image sensor in a format called "RAW". These can be up to 6 times bigger than a JPEG format file. For example a RAW 5760 x 3840 image might use 26MB space on the memory card, while the JPEG uses only 5MB. Some cameras even store one of each when a picture is taken. So you can see there will be a lot of storage space taken up for a smaller number of photos.

So some clarification may be required, If the original image archive as presented is RAW or RAW + JPEG, and the desired end result is a JPEG "family album" type of thing, some work can be done with software to compress the RAW format to JPEG or by simply copying the JPEGS if they are present. If it is desired to keep the RAW data the task takes a different shape. It may be that a tablet or TV or "digital picture frame" may not even recognise RAW images.