Skip to content

Commit 70b81d1

Browse files
committed
feat: add custom makers and cursors support for PNG format
1 parent 63f2d29 commit 70b81d1

File tree

18 files changed

+1127
-55
lines changed

18 files changed

+1127
-55
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
/assets/HeroExpert.png
12
/vendor
23
/public
3-
/assets
44
/composer.lock
55
/phpunit.xml

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) [2024] [HeroExpert]
3+
Copyright (c) [2025] [AmirezaEb] and [HeroExpert]
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 83 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,49 @@
11
# HeroQR Library
22

3-
HeroQR is an advanced and modular PHP library designed to simplify the creation, customization, and management of QR codes. Whether you need a basic QR code or a highly customized one with embedded logos and colors, HeroQR has you covered.
3+
HeroQR is an advanced and modular PHP library designed to simplify the creation, customization, and management of QR codes. Whether you need a basic QR code or a highly customized one with embedded logos, colors, markers, and cursors, HeroQR has you covered. You can fully customize the appearance of your QR code by adjusting the markers (for corner customization) and cursors (for design enhancements). This level of customization allows you to tailor your QR codes to fit your needs precisely.
4+
5+
## Table of Contents
6+
7+
- [HeroQR Library](#heroqr-library)
8+
- [Features](#features)
9+
- [Installation](#installation)
10+
- [Getting Started](#getting-started)
11+
- [1. Basic Usage](#1-basic-usage)
12+
- [2. Advanced Customization](#2-advanced-customization)
13+
- [3. Customizing Markers and Cursors (PNG Only)](#3customizing-markers-and-cursors-png-only)
14+
- [4. Advanced Output Options](#4-advanced-output-options)
15+
- [Project Structure](#project-structure)
16+
- [Contributing](#contributing)
17+
- [License](#license)
18+
- [Contact](#contact)
19+
420

521
## Features
622

723
- **Unmatched Customization :**
824
- Adjust logo size and add logos to the QR code.
925
- Add labels with customizable color, size, text alignment, and margin.
10-
- Support for various encoding formats such as UTF-8 and other standard formats.
11-
- Change the color of the QR code along with the background color.
26+
- Support for various encoding formats such as BASE64, UTF-8, UTF-16, and other standard formats.
27+
- Change the color of the QR code along with the background color, with the ability to adjust the transparency of the colors.
1228
- Automatically adjust the QR code layout and margin.
1329

14-
- **Multi-Format Data Encoding :** Effortlessly encode URLs, text, emails, business cards, and payment information.
30+
- **Customizable Markers and Cursors :** HeroQR allows you to customize the QR code markers and cursors, giving you enhanced control over the design. This feature is available exclusively for PNG output. To customize the markers and cursors, use generate('png-M1-C1'), where:
31+
32+
- `M1` specifies the marker type.
33+
- `C1` specifies the cursor type.
34+
- Available marker and cursor types:
35+
- **Markers :** `M1` `M2` `M3`
36+
- **Cursors :** `C1` `C2` `C3`
37+
38+
- **Note** : This feature is currently limited to PNG format due to its advanced rendering capabilities, but support for other formats will be available in future releases.
39+
40+
41+
- **Multi-Format Data Encoding :** Easily encode various data types, including URLs, text, emails, business cards, and payment information, providing versatility for your QR code needs.
42+
1543
- **Data Validation :** The library supports validation for various data types, including URL, text, email, phone number, IP, and Wi-Fi, ensuring the accuracy of input data.
16-
- **Flexible Export Options :** Save QR codes in multiple formats, including PDF, SVG, PNG, Binary, GIF, EPS, and WebP, ensuring compatibility with different projects.
44+
45+
- **Flexible Export Options :** Save QR codes in multiple formats, including PDF, SVG, PNG, Binary, GIF, EPS, and WebP. If you don't require custom markers or cursors, you can choose from these formats for your output.
46+
-
1747
- **Framework Ready :** Seamlessly integrates with frameworks like Laravel, making it a perfect fit for modern applications.
1848

1949
## Installation
@@ -29,7 +59,7 @@ composer require amirezaeb/heroqr
2959

3060
### 1. Basic Usage
3161

32-
Generate a simple QR code in just a few lines of code:
62+
- Generate a simple QR code in just a few lines of code:
3363

3464
#### Example :
3565

@@ -43,8 +73,8 @@ $qrCodeManager = new QRCodeGenerator();
4373
$qrCode = $qrCodeManager
4474
# Set the data to be encoded in the QR code
4575
->setData('https://test.org')
46-
# Generate the QR code in PNG format
47-
->generate('png') ;
76+
# Generate the QR code in PNG format (default)
77+
->generate() ;
4878

4979
# Save the generated QR code to a file named 'qrcode.png'
5080
$qrCode->saveTo('qrcode');
@@ -54,8 +84,8 @@ $qrCode->saveTo('qrcode');
5484

5585
**Fully customize the appearance and functionality of your QR code while ensuring data validation:**
5686

57-
- **Customization Options**: You can modify various parameters such as size, color, logo, and other visual aspects.
58-
- **Automatic Data Validation**: By using `DataType` (optional), the library automatically validates the type of data being encoded (Url, Email, Phone, Location, Wifi , Text).
87+
- **Customization Options :** You can modify various parameters such as size, color, logo, and other visual aspects.
88+
- **Automatic Data Validation :** By using `DataType` (optional), the library automatically validates the type of data being encoded (Url, Email, Phone, Location, Wifi , Text).
5989

6090
#### Example :
6191

@@ -100,21 +130,48 @@ $qrCode->saveTo('custom-qrcode');
100130

101131
With these options, you can create visually appealing QR codes that align with your design needs.
102132

103-
### 3. Advanced Output Options
133+
### 3. Customizing Markers and Cursors (PNG Only)
134+
135+
- HeroQR allows you to customize the markers and cursors of the QR code. This feature is exclusive to PNG output, and you must specify the output format using generate('png-M1-C1'), where M1 is the marker type and C1 is the cursor type. Currently, only the following options are available:
136+
- **Markers :** `M1`, `M2`, `M3`
137+
- **Cursors :** `C1`, `C2`, `C3`
138+
139+
#### Example :
140+
141+
```php
142+
use HeroQR\Core\QRCodeGenerator;
104143

105-
HeroQR supports advanced output options for greater flexibility when generating QR codes:
144+
$qrCode = $qrCodeManager
145+
->setData('https://example.com')
146+
->setSize(800)
147+
->setBackgroundColor('#ffffffFF')
148+
->setColor('#000000')
149+
# Customize the markers and Cursors (M1 for marker, C1 for Cursor)
150+
->generate('png-M1-C1');
151+
152+
# Save the generated QR code with custom markers and Cursors
153+
$qrCode->saveTo('custom-markers-qr');
154+
```
155+
- **Example Output :** The following images showcase QR codes generated with different marker and cursor configurations in this order : ['M1-C1', 'M2-C2', 'M3-C3'].
106156

107-
- **Matrix Output** : Represent the QR code as a matrix (2D array) of bits, where each block of the matrix corresponds to a specific piece of the encoded data. You can retrieve the matrix in two forms:
157+
<img src="https://raw.githubusercontent.com/AmirezaEb/AmirezaEb/main/assets/img/QrCode/Qr-M1-C1.png" width="100" height="100" />
158+
<img src="https://raw.githubusercontent.com/AmirezaEb/AmirezaEb/main/assets/img/QrCode/Qr-M2-C2.png" width="100" height="100" />
159+
<img src="https://raw.githubusercontent.com/AmirezaEb/AmirezaEb/main/assets/img/QrCode/Qr-M3-C3.png" width="100" height="100" />
160+
161+
### 4. Advanced Output Options
162+
163+
HeroQR provides advanced output capabilities, offering flexibility and compatibility for various use cases, from web embedding to raw data manipulation:
164+
- **Matrix Output :** Represent the QR code as a matrix (2D array) of bits, where each block of the matrix corresponds to a specific piece of the encoded data. You can retrieve the matrix in two forms:
108165
- As a `Matrix` object.
109166
- As a 2D array, which makes it easier to manipulate or display directly in some applications.
110167

111-
- **Base64 Encoding** : Generate the QR code as a Base64-encoded string, which is ideal for embedding directly in HTML, emails, or other media.
168+
- **Base64 Encoding :** Generate the QR code as a Base64-encoded string, which is ideal for embedding directly in HTML, emails, or other media.
112169

113-
- **Data URI** : Get the QR code as a Data URI, which is a compact string representation of the image that can be embedded directly into HTML.
170+
- **Data URI :** Get the QR code as a Data URI, which is a compact string representation of the image that can be embedded directly into HTML.
114171

115-
- **Saving to Different Formats** : You can save the QR code in a variety of formats such as PNG, SVG, GIF, WebP, EPS, PDF, Binary, and more. The format is automatically determined based on the desired output type.
172+
- **Saving to Different Formats :** You can save the QR code in a variety of formats such as PNG, SVG, GIF, WebP, EPS, PDF, Binary, and more. The format is automatically determined based on the desired output type.
116173

117-
#### Example :
174+
#### Example
118175

119176
```php
120177

@@ -136,12 +193,14 @@ $qrCode->saveTo('qr_code_output');
136193
```
137194

138195
## Project Structure
139-
The modular structure of HeroQR ensures ease of use and scalability:
140196

141-
- **Contracts :** Defines interfaces for the core components, ensuring consistency across the system.
142-
- **Core :** Contains the main logic for generating and managing QR codes.
143-
- **DataTypes :** Handles definitions for the various types of data (Location, Url, Email, Phone, Text) and performs automatic validation for each type, so users don’t need to validate data manually.
144-
- **Managers :** Manages the customization and processing of QR codes, providing maximum flexibility for users.
197+
- The modular structure of HeroQR is designed to enhance efficiency and scalability, making it easier to use, maintain, and expand:
198+
199+
- **Contracts :** Defines interfaces for the core components, ensuring consistency and reusability across the system.
200+
- **Core :** Houses the primary logic for generating and managing QR codes, acting as the foundation of the library.
201+
- **DataTypes :** Provides definitions and automatic validation for various data types (wifi, Location, URL, Email, Phone, Text). This eliminates the need for users to manually validate their input.
202+
- **Managers :** Oversees the customization and processing of QR codes, enabling users to have full control over the appearance and functionality of their QR codes.
203+
- **Customs :** The Customs module allows advanced QR code customization, including cursors, markers, line colors, and other visual elements, perfect for creating unique and tailored designs.
145204

146205
## Contributing
147206

@@ -159,11 +218,10 @@ HeroQR is released under the [MIT License](LICENSE), giving you the freedom to u
159218

160219
## Contact
161220

162-
Have questions or suggestions? Let’s connect:
163-
221+
For inquiries or feedback, feel free to reach out via email or GitHub issues :
164222
- **Author :** Amirreza Ebrahimi
165223
- **Email :** aabrahimi1718@gmail.com
166-
- **GitHub :** [AmirrezaEb](https://github.com/AmirezaEb)
224+
- **GitHub Issues :** [GitHub Repository](https://github.com/AmirezaEb/HeroQR/issues)
167225

168226
---
169227

assets/Cursors/Cursor-1.png

10.9 KB
Loading

assets/Cursors/Cursor-2.png

29.5 KB
Loading

assets/Cursors/Cursor-3.png

19.4 KB
Loading

assets/Markers/Marker-1.png

9.5 KB
Loading

assets/Markers/Marker-2.png

31.2 KB
Loading

assets/Markers/Marker-3.png

26.3 KB
Loading

composer.json

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@
22
"name": "amirezaeb/heroqr",
33
"description": "A Powerful QR Code Management Library For PHP",
44
"keywords": [
5-
"AmirezaEb",
6-
"qrcode",
75
"qr",
8-
"management",
6+
"php",
97
"code",
10-
"php"
8+
"qrcode",
9+
"HeroQR",
10+
"laravel",
11+
"qr-codes",
12+
"AmirezaEb",
13+
"management",
14+
"php-library"
1115
],
1216
"homepage": "https://github.com/AmirezaEb/HeroQR",
13-
"version": "1.0.4",
1417
"type": "library",
1518
"license": "MIT",
1619
"authors": [
@@ -49,4 +52,4 @@
4952
]
5053
}
5154
}
52-
}
55+
}

0 commit comments

Comments
 (0)