Update smma/imagemagick.md

This commit is contained in:
2024-05-31 02:33:07 +00:00
parent 993bcf4b77
commit 2b56243805

View File

@@ -1,8 +1,3 @@
Certainly! Here is a simplified `README.md` that provides clear instructions for setting up the project, cloning the repository, and updating the `zsh` configuration for the alias.
### README.md
```markdown
# Image Converter # Image Converter
This project provides a script to convert WEBP and HEIC images to PNG and JPG formats using ImageMagick. This project provides a script to convert WEBP and HEIC images to PNG and JPG formats using ImageMagick.
@@ -11,27 +6,41 @@ This project provides a script to convert WEBP and HEIC images to PNG and JPG fo
### Prerequisites ### Prerequisites
Make sure you have ImageMagick installed. You can check if it's installed by running: #### Install Homebrew
To install Homebrew, run the following command:
```bash ```bash
convert -version /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
``` ```
If not installed, you can install it using: After installation, add Homebrew to your PATH:
- For **zsh** (default for macOS Catalina and later):
```bash
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zshrc
source ~/.zshrc
```
- For **bash**:
```bash
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.bash_profile
source ~/.bash_profile
```
#### Install ImageMagick
With Homebrew installed, run the following command to install ImageMagick:
- **macOS**:
```bash ```bash
brew install imagemagick brew install imagemagick
``` ```
- **Ubuntu**: Verify the installation by checking the version:
```bash
sudo apt-get update
sudo apt-get install imagemagick
```
- **Windows**: ```bash
Download and install from the [ImageMagick website](https://imagemagick.org/script/download.php). magick --version
```
### Project Setup ### Project Setup
@@ -54,7 +63,7 @@ If not installed, you can install it using:
Replace `~/path_to_your_script_directory` with the actual path where you cloned the repository. Replace `~/path_to_your_script_directory` with the actual path where you cloned the repository.
## Usage ### Usage
To convert a WEBP or HEIC file to PNG and JPG, use the following command: To convert a WEBP or HEIC file to PNG and JPG, use the following command:
@@ -69,11 +78,30 @@ convert filename.heic
``` ```
The converted files will be saved in `~/Pictures/Converted`. The converted files will be saved in `~/Pictures/Converted`.
### Maintenance Commands
Keep Homebrew and its packages up-to-date with the following commands:
- **Update Homebrew**:
```bash
brew update
``` ```
### Complete Project Code - **Upgrade installed packages**:
```bash
brew upgrade
```
- **Cleanup old versions**:
```bash
brew cleanup
```
## Complete Project Code
### Project Directory Structure
1. **Project Directory Structure**:
``` ```
image-converter/ image-converter/
├── convert_images.sh ├── convert_images.sh
@@ -81,7 +109,8 @@ The converted files will be saved in `~/Pictures/Converted`.
└── .gitignore └── .gitignore
``` ```
2. **convert_images.sh**: ### convert_images.sh
```bash ```bash
#!/bin/bash #!/bin/bash
@@ -136,84 +165,15 @@ The converted files will be saved in `~/Pictures/Converted`.
fi fi
``` ```
3. **.gitignore**: ### .gitignore
```gitignore ```gitignore
# Ignore log files and temp files # Ignore log files and temp files
*.log *.log
*.tmp *.tmp
``` ```
4. **README.md**: ## Final Steps
```markdown
# Image Converter
This project provides a script to convert WEBP and HEIC images to PNG and JPG formats using ImageMagick.
## Setup Instructions
### Prerequisites
Make sure you have ImageMagick installed. You can check if it's installed by running:
```bash
convert -version
```
If not installed, you can install it using:
- **macOS**:
```bash
brew install imagemagick
```
- **Ubuntu**:
```bash
sudo apt-get update
sudo apt-get install imagemagick
```
- **Windows**:
Download and install from the [ImageMagick website](https://imagemagick.org/script/download.php).
### Project Setup
1. **Clone the repository**:
```bash
git clone https://github.com/yourusername/image-converter.git
cd image-converter
```
2. **Make the script executable**:
```bash
chmod +x convert_images.sh
```
3. **Add an alias to your shell configuration file**:
```bash
echo "alias convert='~/path_to_your_script_directory/convert_images.sh'" >> ~/.zshrc
source ~/.zshrc
```
Replace `~/path_to_your_script_directory` with the actual path where you cloned the repository.
## Usage
To convert a WEBP or HEIC file to PNG and JPG, use the following command:
```bash
convert filename.webp
```
or
```bash
convert filename.heic
```
The converted files will be saved in `~/Pictures/Converted`.
```
### Final Steps
1. **Initialize Git Repository**: 1. **Initialize Git Repository**:
```bash ```bash
@@ -231,50 +191,3 @@ The converted files will be saved in `~/Pictures/Converted`.
git branch -M main git branch -M main
git push -u origin main git push -u origin main
``` ```
Now, anyone can clone your repository and follow the instructions in the `README.md` to set up and use the image conversion script.
---
# Install Homebrew
```bash
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
```
# Update your PATH
```bash
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zshrc
```
# Update your shell
```bash
source ~/.zshrc
```
# Install ImageMagick
```bash
brew install imagemagick
```
# Verify the installation
```bash
magick --version
```
---
> Keep Homebrew up-to-date
# Update Homebrew
```bash
brew update
```
# Upgrade installed packages
```bash
brew upgrade
```
# Cleanup old versions
```bash
brew cleanup
```