Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add logo to the middle of qr code? #25

Open
fuatberk opened this issue Oct 5, 2018 · 10 comments
Open

Add logo to the middle of qr code? #25

fuatberk opened this issue Oct 5, 2018 · 10 comments

Comments

@fuatberk
Copy link

fuatberk commented Oct 5, 2018

Hello,

How can we do that?
QR I want to add logo to the middle of code?

@IniAku
Copy link

IniAku commented Nov 30, 2018

hi BR9, have you resolve it? I need it too

@robikurniawan
Copy link

same, i need it

@IniAku
Copy link

IniAku commented May 2, 2019

same, i need it

i have solved it... perhaps i will tell tomorrow, need to sleep today :D

@robikurniawan
Copy link

thanks before.

@rusyaidisupian
Copy link

same, i need it

i have solved it... perhaps i will tell tomorrow, need to sleep today :D

how you make it?can you share it? i really need to know

@IniAku
Copy link

IniAku commented Jul 14, 2019

here is my code for adding the logo... sory taking so long, I am on a full busy day..
`$this->config->load('logoqrcode',TRUE);
$logolocation = $this->config->item('qrcodelogo', 'logoqrcode');
$qrlocation = "$codepath.png";
$QR = imagecreatefrompng("$codepath.png");
$logo = imagecreatefrompng($logolocation);
imagecolortransparent($logo , imagecolorallocatealpha($logo , 0, 0, 0, 127));
imagealphablending($logo , false);
imagesavealpha($logo , true);

							$QR_width = imagesx($QR);
							$QR_height = imagesy($QR);

							$logo_width = imagesx($logo);
							$logo_height = imagesy($logo);

							// Scale logo to fit in the QR Code
							$logo_qr_width = $QR_width/3;
							$scale = $logo_width/$logo_qr_width;
							$logo_qr_height = $logo_height/$scale;

							imagecopyresampled($QR, $logo, $QR_width/3, $QR_height/3, 0, 0, $logo_qr_width, $logo_qr_height, $logo_width, $logo_height);
							/*}*/
							imagepng($QR, $qrlocation);
							imagedestroy($QR);`

There it is, thank you all

@rusyaidisupian
Copy link

rusyaidisupian commented Jul 15, 2019 via email

@juliarnasution
Copy link

@rusyaidisupian
this is my code, you can try it
`public function generate_qr_code($value)
{
$filename = $value.'.png';
$fullpath = APPPATH.'../public/files/'.$filename;
$logopath = APPPATH.'../assets/img/logo/kemdikbud.png';
unlink($fullpath);
if (!file_exists($fullpath)) {
$this->load->library('ciqrcode');
$params['data'] = $value;
$params['level'] = 'H';
$params['size'] = 10;
$params['savename'] = $fullpath;
$this->ciqrcode->generate($params);
$QR = imagecreatefrompng($fullpath);
// memulai menggambar logo dalam file qrcode
$logo = imagecreatefromstring(file_get_contents($logopath));
imagecolortransparent($logo , imagecolorallocatealpha($logo , 0, 0, 0, 127));
imagealphablending($logo , false);
imagesavealpha($logo , true);
$QR_width = imagesx($QR);//get logo width
$QR_height = imagesy($QR);//get logo width

         $logo_width = imagesx($logo);
         $logo_height = imagesy($logo);
         // Scale logo to fit in the QR Code
         $logo_qr_width = $QR_width/2;
         $scale = $logo_width/$logo_qr_width;
         $logo_qr_height = $logo_height/$scale;

         imagecopyresampled($QR, $logo, $QR_width/4, $QR_height/3.5, 0, 0, $logo_qr_width, $logo_qr_height, $logo_width, $logo_height);
         // Simpan kode QR lagi, dengan logo di atasnya
         imagepng($QR,$fullpath);
    }
     return $filename;
}`

@kik-doctor
Copy link

kik-doctor commented Jan 31, 2020 via email

@mdestafadilah
Copy link

hello, how are you? Why do you send me this rubbish code ? Who do you think I am ?

On Thu, Jan 30, 2020 at 9:13 PM Juliar Nasution @.***> wrote: @rusyaidisupian https://github.com/rusyaidisupian this is my code, you can try it public function generate_qr_code($value) { $filename = $value.'.png'; $fullpath = APPPATH.'../public/files/'.$filename; $logopath = APPPATH.'../assets/img/logo/kemdikbud.png'; unlink($fullpath); if (!file_exists($fullpath)) { $this->load->library('ciqrcode'); $params['data'] = $value; $params['level'] = 'H'; $params['size'] = 10; $params['savename'] = $fullpath; $this->ciqrcode->generate($params); $QR = imagecreatefrompng($fullpath); // memulai menggambar logo dalam file qrcode $logo = imagecreatefromstring(file_get_contents($logopath)); imagecolortransparent($logo , imagecolorallocatealpha($logo , 0, 0, 0, 127)); imagealphablending($logo , false); imagesavealpha($logo , true); $QR_width = imagesx($QR);//get logo width $QR_height = imagesy($QR);//get logo width $logo_width = imagesx($logo); $logo_height = imagesy($logo); // Scale logo to fit in the QR Code $logo_qr_width = $QR_width/2; $scale = $logo_width/$logo_qr_width; $logo_qr_height = $logo_height/$scale; imagecopyresampled($QR, $logo, $QR_width/4, $QR_height/3.5, 0, 0, $logo_qr_width, $logo_qr_height, $logo_width, $logo_height); // Simpan kode QR lagi, dengan logo di atasnya imagepng($QR,$fullpath); } return $filename; } — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#25?email_source=notifications&email_token=AMYJ22F6DZB5RVNY6P5XFDDRALHADA5CNFSM4FZIIRWKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKK5WRY#issuecomment-580246343>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMYJ22FIPSIYSKQG4ZEWFELRALHADANCNFSM4FZIIRWA .

It's easy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants