Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

EPS file format isn't providing the right output #274

Answered by codemasher
Vischerkarpfen asked this question in Q&A
Discussion options

For our design department we created a QRCode generator in our CMS using Chillerlan/php-qrcode. We use PHP Version 7.4 with php-qrcode version 5.0.2. Now they were asking for the file format to be EPS, although it's an old file format and you could just use modern svg.

I used the example provided in Eps.php. The problem is that our design can't open the generated qrcode.eps file in either Adobe Illustrator and InDesign. We have some qrcodes from other generators in EPS file format so I opened both files in an editor to compare them. I noticed that the generated qrcode.eps file from chillerlan/php-qrcode just contains a few lines of xml / html syntax while the qrcodes generated from other files in .eps look more like an actual .eps file. Is there a reason and solution to this?
Below is the code of both .eps files on pastebin:

qrcode.eps (chillerlan):
https://pastebin.com/k1ne0tKB

qrcode.eps (qrcode Monkey):
https://pastebin.com/87M86KQT

You must be logged in to vote

That is because the output isn't EPS but SVG, most likely because you're using an example from dev-main. See: https://github.com/chillerlan/php-qrcode?tab=readme-ov-file#documentation

Replies: 1 comment 9 replies

Comment options

That is because the output isn't EPS but SVG, most likely because you're using an example from dev-main. See: https://github.com/chillerlan/php-qrcode?tab=readme-ov-file#documentation

You must be logged in to vote
9 replies
Comment options

@codemasher Hey there again! Could I may ask, if there is an option to exclude some modules from being drawn as the custom shape I defined? Currently I've overwritten the module() method to draw a rhombus-like shape and literally everything will be drawn like that. But I want to draw everything else (especially the finders and their dots) as usual squares.

Comment options

Hey, I think this is what you're looking for (see also #150):

if(
!$this->matrix->isDark($M_TYPE)
// we're skipping the finder patterns here
|| $this->matrix->checkType($x, $y, QRMatrix::M_FINDER)
|| $this->matrix->checkType($x, $y, QRMatrix::M_FINDER_DOT)
){
return '';
}
// return a heart shape (or any custom shape for that matter)
return sprintf('M%1$s %2$s m0.5,0.96 l-0.412,-0.412 a0.3 0.3 0 0 1 0.412,-0.435 a0.3 0.3 0 0 1 0.412,0.435Z', $x, $y);
Comment options

My biggest respect and gratitude that you answer so fast. You seem very dedicated in this wonderful masterpiece of a library! Thank you for your answer! At the same time I have to apologize. I wasted your time, because before you answered I continued searching for an answer myself of course and found the exact same code you just referred to. ^^'
I'm a junior dev, completely new to php (3 months of experience in that language) coming from the C# world so please forgive me my unexperience.

But that leads me to another question. I just used that, but obviously now it's just skipping the finders and leaves them blank (white/not visible). I don't really understand where I can define them to be usual squares.

Comment options

Well we all started at some point haha. Glad to be of help - it's nothing really.

I don't really understand where I can define them to be usual squares.

You just take the bit above that checks for the finder patterns and put it into another if(...) and return the square blocks there.
Basically:

// light module (return empty)
if(!$this->drawLightModules && !$this->matrix->isDark($M_TYPE)){ 
 return ''; 
}
// determine position as in the EPS output class
// ...
// return square shape for the given types
if($this->matrix->checkType($x, $y, QRMatrix::M_FINDER) || $this->matrix->checkType($x, $y, QRMatrix::M_FINDER_DOT)){
 return sprintf('%d %d %d %d F', $outputX, $outputY, $this->scale, $this->scale);
}
// return custom shape
return '...';
Comment options

Worked all like a hot knife is slicing butter! Thank you so much, I learned a looot today. :) Realized the same thing in png myself at least. To further continue learning myself, next step will be trying to do rounded corners except one for the finders without help.^^

Answer selected by Vischerkarpfen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /