Jump to content
MakeWebGames

Recommended Posts

Posted (edited)

I have this so far.

Working on the Download part atm which is getting me for the moment. I might have it just update the display_pic in users settings or both.

 

1.png

1.png.3c9268796fbaa24aa3494fa4efcb0cd8.png

Edited by peterisgb
Latest Screenshot
  • Like 3
Posted

Me and magictallguy have been working on the mccodes avataaar for most of today. V1.0.1 will hopefully be on the market place later tonight once the final touches are done.

 

  • Like 1
Posted (edited)

Force download with imagelng/imagegif or even file_get_contents ? Im sure you are also aware of changing the header of pages? Can change to image to force it to pop up as download?

Edited by Sim
Posted
6 hours ago, Sim said:

Force download with imagelng/imagegif or even file_get_contents ? Im sure you are also aware of changing the header of pages? Can change to image to force it to pop up as download?

The original image is an SVG.
PHP doesn't have any native image handling libraries and GD (usually compiled with PHP by default these days) can't support the SVG format.
If you've got Imagick installed, then you're good to go. If not, then I recommend a 3rd party service such as CloudConvert, they have an API exposed (in a format you're more accustomed to, Sim) that allows you to convert on-demand from within your own site.

Posted (edited)
3 hours ago, Magictallguy said:

The original image is an SVG.
PHP doesn't have any native image handling libraries and GD (usually compiled with PHP by default these days) can't support the SVG format.
If you've got Imagick installed, then you're good to go. If not, then I recommend a 3rd party service such as CloudConvert, they have an API exposed (in a format you're more accustomed to, Sim) that allows you to convert on-demand from within your own site.

Do you store the raw SVG data? or the link to the image based on the options supplied? 

Could you do something like:

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

It's been a really loooong time, so if I'm way off, sorry 🙂

Edit: Realised SVGs aren't useful to the normal folk for use as images, scrap the above.

Edited by Djkanna
  • Like 1
Posted (edited)
6 hours ago, Sim said:

Is it possible to get the source to add to mines? 

Oh, Nope sorry, Its all inhouse to my mods only.
Welcome to take the idea and build your own.
I may in the future once my system is set up fully to allow users to use it, but that wont be till new year at the Earliest. 

Edited by peterisgb
Posted (edited)
On 8/28/2020 at 3:16 PM, Djkanna said:

Do you store the raw SVG data? or the link to the image based on the options supplied? 

Could you do something like:

$img = file_get_contents ( 'https://avataaars.io/?avatarStyle=Circle&topType=LongHairStraight&accessoriesType=Blank&hairColor=BrownDark&facialHairType=Blank&clotheType=BlazerShirt&eyeType=Default&eyebrowType=Default&mouthType=Default&skinColor=Light%27' ); if ( $img ) { header( 'Content-type: image/svg+xml' ); header( 'Content-Disposition: attachment; filename=avatar_download.svg' ); echo $img; }

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

It's been a really loooong time, so if I'm way off, sorry 🙂

Edit: Realised SVGs aren't useful to the normal folk for use as images, scrap the above.

Wasn't letting it get the best of me after a little browsing/trial and error, providing you use the SVG as the image preview - Pure JS method of download SVG as png. 🙂

*Works in most decent browsers, the 'download' attribute is hit and miss. 

https://codepen.io/MrDJK/pen/ZEWyPMa

 

Alternatively, combine both solutions: instead of creating download link do*:
 

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

*Probably have to increase the URI limit, or do post request instead of get.

Edited by Djkanna
Cannot spell. - 2nd: Added alternative
  • Like 3
Posted
16 hours ago, Djkanna said:

Wasn't letting it get the best of me after a little browsing/trial and error, providing you use the SVG as the image preview - Pure JS method of download SVG as png. 🙂

*Works in most decent browsers, the 'download' attribute is hit and miss. 

https://codepen.io/MrDJK/pen/ZEWyPMa

 

Alternatively, combine both solutions: instead of creating download link do*:
 

window.location.href = 'download.php?img='+dataURL.replace('data:image/png;base64,', '');

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

if ( $_GET['img'] ) { header( 'Content-type: image/png' ); header( 'Content-Disposition: attachment; filename=avatar_download.png' ); echo $_GET['img']; }

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

*Probably have to increase the URI limit, or do post request instead of get.

Heh, we ended up doing something quite similar. Nicely done! 🙂

  • Like 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...