• Hey there. I’m trying to do some image manipulation for a custom plugin, and some of it requires a bit more than the WP_Image_Editor really provides (Like making new images), and part of my requirements is to manipulate a WP_Image_Editor image in GD, and I’d rather not deal with files.

    I tried using the WP_Image_Editor::stream function, but it seems to always return 1 when I put that output into the error_log.

    My code is here:

    function wpToGD($image_wp){
        error_log(print_r($image_wp->stream()));
        return imagecreatefromstring($image_wp->stream());
    }

    Is there something I’m missing here? Thanks.

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    From my experience, it seems the error_log() function is very limiting in what it’ll actually write to the log file. I’m unsure of the actual limitations, but something along the line of only ASCII-127 chars and less than a certain length is what I’ve assumed.

    For debug output try using the output buffer, saving it to a global for later echoing out when the browser is accepting output. Another approach is passing the output as message content to wp_mail() – so you email yourself the debug output. Use print_r( $image_wp->stream(), true ) for this.

    As for using GD, I know very little. Could you possibly instantiate WP_Image_Editor_GD class?

Viewing 1 replies (of 1 total)
  • The topic ‘Getting a GD image from WP_Image_Editor’ is closed to new replies.