Skip to content

Commit

Permalink
chore - Update README, reformat comments in the source code
Browse files Browse the repository at this point in the history
  • Loading branch information
cdefgah committed Feb 12, 2021
1 parent 6771a0e commit f01a9a1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 24 deletions.
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@

[![](https://github.com/cdefgah/whatsapp-jpeg-repair/workflows/build/badge.svg)](https://github.com/cdefgah/whatsapp-jpeg-repair/actions)

When you send jpeg files via WhatsApp and afterwards try to open received jpeg files in the Adobe Photoshop, there is a chance to get the following error in Photoshop:
When you are sent jpeg files via WhatsApp and then try to open received files in the Adobe Photoshop, there's a chance you'll get the following error in Photoshop:

`Could not complete your request because a SOFn, DQT, or DHT JPEG marker is missing before a JPEG SOS marker`

For such cases users advised to open the broken file in MS Paint (or something similar on MacOS) and save it as jpeg file. Usually it helps, but when you have many broken image files, opening and saving every file is a kind of tedious work.
For this case users are usually advised to open the broken file in MS Paint (or something similar in MacOS) first and save it as jpeg file. Usually it helps, but when you have many broken image files, opening and saving them one by one may get a little tedious.

WhatsApp Jpeg Image Repair application solves this problem and can repair multiple broken files at once.
WhatsApp Jpeg Image Repair application solves this problem by repairing multiple broken files at once.

Follow these steps:
1. Download application archive. Navigate to [the application releases](https://github.com/cdefgah/whatsapp-jpeg-repair/releases). Then expand `Assets` section and download application zip archive relevant to your operating system.
2. Unzip application archive to an arbitrary folder. I recommend to use your home folder, for example `Documents` or `Desktop` folder, to prevent filesystem access control issues upon running the application. If you use MacOS, please note that MacOS Gatekeeper blocks this application when you try to launch it. To run downloaded application on MacOS your should either [disable MacOS Gatekeeper](https://www.google.com/search?q=disable+MacOS+Gatekeeper) or build the application from the source code as described hereinafter, and replace existing executable in downloaded zip-archive with the new executable file you have built from the source code.
1. Download application archive. Navigate to [the application releases](https://github.com/cdefgah/whatsapp-jpeg-repair/releases). Then expand `Assets` section and download application zip archive suitable for your operating system.
2. Unzip application archive to the folder of your choosing, preferrably your home folder, e.g. `Documents` or `Desktop` folder, to prevent filesystem access control issues upon running the application. If you use MacOS, please note that MacOS Gatekeeper blocks this application when you try to launch it. To run downloaded application on MacOS your should either [disable MacOS Gatekeeper](https://www.google.com/search?q=disable+MacOS+Gatekeeper) or build the application from the source code as described below, and replace existing executable in downloaded zip archive with the newly-built file.
3. Open application folder `WhatsAppJpegRepair`.
4. Place broken jpeg files from WhatsApp to the `whatsapp-files` directory, located in the application folder.
5. Run the application.
6. Go to the `fixed-files` folder to get fixed image files.
6. Go to the `fixed-files` folder to get repaired image files.

There are following option available:
Options and switches:

`-srcPath` - contains path to the broken WhatsApp files
By default the application internal folder `whatsapp-files` is being used.
Expand All @@ -31,33 +31,33 @@ WhatsAppJpegRepair -srcPath=/home/username/Documents/Photos/WhatsAppFiles

this call will use `/home/username/Documents/Photos/WhatsAppFiles` folder as the source path to get broken whatsapp files.

`-destPath` - contains path to the folder, where fixed files will be stored.
`-destPath` - contains path to the folder, where repaired files will be stored.
By default the application internal folder `fixed-files` is being used.
If this folder does not exist, it will be created at runtime.

Example:
```
WhatsAppJpegRepair -srcPath=/home/username/Documents/Photos/WhatsAppFiles -destPath=/home/username/Documents/FixedPhotos
```
this call will use `/home/username/Documents/Photos/WhatsAppFiles` folder to look for broken whatsapp files, and will use `/home/username/Documents/FixedPhotos` folder to store fixed images.
this call will use `/home/username/Documents/Photos/WhatsAppFiles` folder to look for broken whatsapp files, and will use `/home/username/Documents/FixedPhotos` folder to store repaired images.

`-dontWaitToClose` - if it is set to `true`, the application will be closed just as it finished processing, otherwise it will wait until user presses 'Enter' key. By default its value is `false`.
`-dontWaitToClose` - if it is set to `true`, the application wil close when done, otherwise it will wait until user presses 'Enter'. Default value is `false`.

Example:
```
WhatsAppJpegRepair -srcPath=/home/username/Documents/Photos/WhatsAppFiles -dontWaitToClose=true
```
this call will use folder `/home/username/Documents/Photos/WhatsAppFiles` as a source files path, and application will be closed as it finished files processing. All fixed files will be stored to the default destination folder `fixed-files` (check `-destPath` option description above).
this call will use folder `/home/username/Documents/Photos/WhatsAppFiles` as a source files path, and application will be closed as it finished files processing. All repaired files will be stored to the default destination folder `fixed-files` (check `-destPath` option description above).

`-useCurrentModificationDateTime` - if it is set to `true`, then created fixed files will get current date/time as file modification time. By default it is `false`, and all created fixed files get the same file modification date/time as source (broken) image files.
`-useCurrentModificationDateTime` - when set to `true`, this switch sets current date/time as repaired files' 'modified' attribute. By default it is set `false`: all repaired files retain the same file modification date/time as source (broken) image files.

```
WhatsAppJpegRepair -useCurrentModificationDateTime=true
```
this call will use default source and destination folders (check `-srcPath` and `-destPath` options above), the application will wait until user presses Enter to exit when all files are processed,
and will set current date/time as file modification time for created fixed files.
and current date/time will be set as file modification time for created repaired files.

There are no mandatory options provided. You can run the application without parameters, or set arbitrary set of parameters, for the rest of parameters default values will be applied.
None of these options are mandatory. You can run the application without parameters, or set arbitrary set of parameters, default values will be applied for the rest.

## Building the application from the source

Expand Down
24 changes: 14 additions & 10 deletions WhatsAppJpegRepair.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,15 @@ func repairImageFiles(sourceFolderPath string, destinationFolderPath string, use
return totalFilesCount == processedFilesCount
}

// Processes single jpeg image file.
// sourceFolderPath - path to folder, where broken image files are located.
// sourceFileNameWithExtension contains filename with extension of image file, that should be processed.
// destinationFilesFolderPath contains path to folder, where fixed image file will be stored.
// useCurrentModificationDateTime if true, setting current date/time as file modification time for generated file.
// otherwise preserves source file modification date/time.
// Returns true, if there were no errors upon file processing, false otherwise.
/*
Processes single jpeg image file.
sourceFolderPath - path to folder, where broken image files are located.
sourceFileNameWithExtension contains filename with extension of image file, that should be processed.
destinationFilesFolderPath contains path to folder, where fixed image file will be stored.
useCurrentModificationDateTime if true, setting current date/time as file modification time for generated file.
otherwise preserves source file modification date/time.
Returns true, if there were no errors upon file processing, false otherwise.
*/
func processSingleImageFile(sourceFolderPath string, sourceFileNameWithExtension string, destinationFilesFolderPath string, useCurrentModificationDateTime bool) bool {

var sourceFilePath = filepath.Join(sourceFolderPath, sourceFileNameWithExtension)
Expand Down Expand Up @@ -184,9 +186,11 @@ func processSingleImageFile(sourceFolderPath string, sourceFileNameWithExtension
return true
}

// Loads image from the file.
// filePath contains path to the image file.
// Returns object with saved image, or error, if something went wrong.
/*
Loads image from the file.
filePath contains path to the image file.
Returns object with saved image, or error, if something went wrong.
*/
func getImageFromFilePath(filePath string) (image.Image, error) {
f, err := os.Open(filePath)
if err != nil {
Expand Down

0 comments on commit f01a9a1

Please sign in to comment.