Rewrite code that saves file as png SO it saves as GIF (code in description/file attached)

currently have a meme generator on my website.. it allows me to add jpeg templates... i want to be able to use .gif files instead... but when i save it, it saves as jpg file. i need it to save gif only.

please analyze code below and let me know if u have the skills for this.



* Process image


* @param str $img the file input name.

* @param int $post_id the post ID (with 0 there is no post attached).

* @param str $post_title the post title.


public function mememe_process_image( $img, $post_id = 0, $post_title = 'meme###' ) {

if ( ! $img ) {

return false;


if ( ! function_exists( 'media_handle_upload' ) ) {

require_once( ABSPATH . 'wp-admin/includes/[login to view URL]' );

require_once( ABSPATH . 'wp-admin/includes/[login to view URL]' );

require_once( ABSPATH . 'wp-admin/includes/[login to view URL]' );


// $upload_dir = wp_upload_dir()

$img = str_replace( 'data:image/png;base64,', '', $img );

$img = str_replace( ' ', '+', $img );

$data = base64_decode( $img );

$source = imagecreatefromstring( $data );

if ( false !== $source ) {

// Set a custom upload directory.

add_filter( 'upload_dir', array( $this, 'custom_upload_dir' ) );

$upload_dir = wp_upload_dir();

$upload_path = str_replace( '/', DIRECTORY_SEPARATOR, $upload_dir['path'] ) . DIRECTORY_SEPARATOR;

// Reflect the meme slug.

$meme_slug = mememe_admin()->get_option( 'mememe_option_slug', 'mememe' );

$base_title = 'meme###' == $post_title ? $meme_slug : sanitize_title( $post_title );

$image_name = $base_title . '-' . $post_id . '.jpg';

$image_upload = imagejpeg( $source, $upload_path . $image_name, 100 );

// @new use $file instead of $source

$file = array();

$file['error'] = '';

$file['tmp_name'] = $upload_path . $image_name;

$file['name'] = $image_name;

$file['type'] = 'image/png';

$file['size'] = filesize( $upload_path . $image_name );

// Upload file to server.

$file_return = media_handle_sideload( $file, $post_id );

imagedestroy( $source );

// Reset to default uploads directory.

remove_filter( 'upload_dir', array( $this, 'custom_upload_dir' ) );

return $file_return;

} else {

return false;



Kemahiran: PHP, Wordpress, MySQL, JavaScript, CSS

Lihat lagi: doxygen png jpg gif file size, excel description dependent code, myspace upcoming events description html code, gif image header code, j2me games description source code, website flex animated gif logo html code website, description ardrone_navigation code, rewrite creative title small description keywords photos, attached code, animated png vs gif, imagemagick convert png to gif, animated png to gif, convert gif to html code, python convert png to gif, png to gif, description of code 94799, rename png to gif, convert png to gif animation, convert gif to embed code

Tentang Majikan:
( 70 ulasan ) port orange, United States

ID Projek: #32205986

Dianugerahkan kepada:

(85 Ulasan)

10 pekerja bebas membida secara purata $21 untuk pekerjaan ini


Hi, I've checked the attached code and I can get it done for you so that it saves as GIF. Thanks and I look forward to working with you.

$35 USD dalam sehari
(272 Ulasan)

We can do it! Professionals are accessible 24/7/365 to guide you. Honestly, I possess all the skills and experience that you're looking for. I'm pretty confident that I am the best candidate for this job role. It's no Lagi

$25 USD dalam 7 hari
(75 Ulasan)

Dear Hiring Manager , Today your job posting (Rewrite code that saves file as png SO it saves as GIF (code in description/file attached)) has caught my attention, and I wish to have a conversation about the project. I Lagi

$25 USD dalam 7 hari
(141 Ulasan)

I have some questions regarding the specs that you have provided. Could we please have a word? My Skills: PHP, WordPress, CSS, MySQL and JavaScript

$10 USD dalam 7 hari
(105 Ulasan)

Hi, I've changes to your script that I think they'll get the generated images converted from jpg to gif. I'd like you to contact me on the chat so I can send you the code for you to test it. Thanks!

$20 USD dalam sehari
(75 Ulasan)

Greetings~ I have seen your code so I have a confidence in your task. Please contact me and let me work. Thanks. Olamide.

$10 USD dalam sehari
(3 Ulasan)

Hi, • This is Sairus Khalil from DW Solution online. • I'm certified in web designing and development by freelancer.com. You can also check certificate in my profile. • DW Solution Online is providing Responsive Webs Lagi

$25 USD dalam 7 hari
(1 Ulasan)

I have 3 years of experience in python, django, php. I can edit this code and run it with in one day.(24hrs). Please let me know if intrested.

$25 USD dalam sehari
(0 Ulasan)

hey i can fix your problem for you. i will just send you the code after doing updates in it and it will work fine

$10 USD dalam 7 hari
(0 Ulasan)