check whether mime type indicates web image
(i.e. image/jpeg, image/gif, image/png)

@param bool $force forces re-read of mime type
422415
public function isWebImage($force = false) {

		if(!isset($this->mimetype) || $force) {
			$this->mimetype = MimeTypeGetter::get($this->folder->getPath() . $this->filename);
		}
		return preg_match('~^image/(p?jpeg|png|gif)$~', $this->mimetype);

	}
597849
public function output($type = 'jpg', $quality = 75)
        {
            if($type == 'jpg' && (imagetypes() & IMG_JPG)) {
                header("Content-Type: image/jpeg");
                imagejpeg($this->im, null, $quality);
                return true;
            } elseif($type == 'png' && (imagetypes() & IMG_PNG)) {
                header("Content-Type: image/png");
                imagepng($this->im);
                return true;
            } elseif($type == 'gif' && (imagetypes() & IMG_GIF)) {
                header("Content-Type: image/gif");
                imagegif($this->im);
                return true;
            } else
                return false;
        }
991462
public function check($force = false)
    {
        /*
         * Already know about updates, never retry.
         */
        $oldCount = Parameter::get('system::update.count');
        if ($oldCount > 0) {
            return $oldCount;
        }

        /*
         * Retry period not passed, skipping.
         */
        if (!$force
            && ($retryTimestamp = Parameter::get('system::update.retry'))
            && Carbon::createFromTimeStamp($retryTimestamp)->isFuture()
        ) {
            return $oldCount;
        }

        try {
            $result = $this->requestUpdateList();
            $newCount = array_get($result, 'update', 0);
        }
        catch (Exception $ex) {
            $newCount = 0;
        }

        /*
         * Remember update count, set retry date
         */
        Parameter::set('system::update.count', $newCount);
        Parameter::set('system::update.retry', Carbon::now()->addHours(24)->timestamp);

        return $newCount;
    }
13974
static public function type($file) {
        $type = getimagesize($file);
        $type = $type[2];
        switch($type) {
            case IMAGETYPE_GIF:     return 'gif';
            case IMAGETYPE_JPEG:    return 'jpg';
            case IMAGETYPE_PNG:     return 'png';
        }
        return FALSE;
    }
796041
public function render($force = false) {

        if(empty($this->html) || $force) {

            if($this->selected) {
                $this->attributes['selected'] = 'selected';
            }
            else {
                unset($this->attributes['selected']);
            }

            $this->attributes['value'] = $this->getValue();

            $attr = [];

            foreach($this->attributes as $k => $v) {
                $attr[] = sprintf('%s="%s"', $k, $v);
            }

            $this->html = sprintf(
				'<option %s>%s</option>',
                implode(' ', $attr),
				$this->getLabel()->getLabelText()
			);
		}

		return $this->html;

	}
1032233
public boolean mediaIsGIF () {
        String contentType = this.getContentType();
        return contentType != null && this.media != null && contentType.equals("image/gif");
    }
1073856
public function supportsExif() {
        return $this->_cache(__FUNCTION__, function($file) {
            /** @type \Transit\File $file */

            if (!$file->isImage()) {
                return false;
            }

            return in_array($file->type(), array('image/jpeg', 'image/tiff'));
        });
    }
225960
public static function load($force = false) 
    {
        // already loaded
        if (!$force && self::$_loaded) {
            return false;
        }
        self::_resolveDefaultPath();

        $files = glob(realpath(self::$_path)."/*.php");
        foreach ($files as $file) {
            Log::log("loading factory from $file ...");
            include_once $file;
        }
        self::$_loaded = true;
        return self::$_loaded;
    }
360981
protected function _reindex($force = false)
    {
        $id = $this->getMimeId();

        if (($this->_status & self::STATUS_REINDEX) ||
            ($force && is_null($id))) {
            $this->buildMimeIds(
                is_null($id)
                    ? (($this->getPrimaryType() === 'multipart') ? '0' : '1')
                    : $id
            );
        }
    }
1072273
private void checkFileType() {

        if ((m_fileInput != null) && (m_replaceInfo != null) && (m_fileWidget != null)) {
            CmsFileInfo file = m_fileInput.getFiles()[0];
            if (!m_replaceInfo.getSitepath().endsWith(file.getFileSuffix())) {
                Widget warningImage = FontOpenCms.WARNING.getWidget(
                    20,
                    I_CmsConstantsBundle.INSTANCE.css().colorWarning());
                warningImage.setTitle(Messages.get().key(Messages.GUI_REPLACE_WRONG_FILE_EXTENSION_0));
                warningImage.addStyleName(
                    org.opencms.gwt.client.ui.css.I_CmsLayoutBundle.INSTANCE.listItemWidgetCss().permaVisible());
                m_fileWidget.addButton(warningImage);
            }
        }
    }
75100
public static function isImageTypeSupported($reqtype) {
	    $supportByGD = array('jpg'=>'jpeg', 'jpeg'=>'jpeg', 'gif'=>'gif', 'png'=>'png');
	    $reqtype = strtolower($reqtype);
	
	    if (empty($supportByGD[$reqtype])) {
	        return false;
	    }
	
	    $type = $supportByGD[$reqtype];
	
	    if (function_exists('imagecreatefrom'.$type) && function_exists('image'.$type)) {
	        return $type;
	    }
	
	    return false;
	}
1075821
private function verifyMimeType($mime_type)
    {
        $allowed = $this->config['allowed_mime_types'];
        if (! empty($allowed) && ! in_array(strtolower($mime_type), $allowed)) {
            throw FileNotSupportedException::mimeRestricted(strtolower($mime_type), $allowed);
        }

        return $mime_type;
    }
504230
public function is_watched( $force = false ) {

		if( !$force && $this->watched !== null ) {
			return $this->watched;
		}

		$tArray = array(
			'action' => 'query',
			'prop'   => 'info',
			'inprop' => 'watched',
			'titles' => $this->title,
		);

		pecho( "Getting watch status for {$this->title}..\n\n", PECHO_NORMAL );

		$tRes = $this->wiki->apiQuery( $tArray );

		if( isset( $tRes['query']['pages'][$this->pageid]['watched'] ) ) {
			$this->watched = true;
		} else $this->watched = false;

		return $this->watched;
	}
793223
function filetype($path)
    {
        $type = $this->_get_stat_cache_prop($path, 'type');
        if ($type === false) {
            return false;
        }

        switch ($type) {
            case NET_SFTP_TYPE_BLOCK_DEVICE:
                return 'block';
            case NET_SFTP_TYPE_CHAR_DEVICE:
                return 'char';
            case NET_SFTP_TYPE_DIRECTORY:
                return 'dir';
            case NET_SFTP_TYPE_FIFO:
                return 'fifo';
            case NET_SFTP_TYPE_REGULAR:
                return 'file';
            case NET_SFTP_TYPE_SYMLINK:
                return 'link';
            default:
                return false;
        }
    }
193093
public static function isGifFile($filename)
    {
        try {
            $image = new ImageFile($filename);
            if (strtolower($image->getMime()) !== @image_type_to_mime_type(IMAGETYPE_GIF)) {
                return false;
            }

            return true;
        } catch (\RuntimeException $ex) {
            return false;
        }
    }
1115160
public function hasTranslations(bool $force = false)
    {
        $this->getTranslations($force);

        return $this->translations_list->isFilled();

    }
618401
public function remove($force = false)
    {
        $isEmpty = $this->isEmpty();
        if ($force && !$isEmpty) {
            $it = new \RecursiveDirectoryIterator($this->dir, \RecursiveDirectoryIterator::SKIP_DOTS);
            $files = new \RecursiveIteratorIterator($it, \RecursiveIteratorIterator::CHILD_FIRST);
            foreach($files as $file) {
                if ($file->isDir()){
                    \rmdir($file->getRealPath());
                } else {
                    \unlink($file->getRealPath());
                }
            }

            \rmdir($this->dir);
            $this->removed = true;

            return;
        }

        if ($isEmpty) {
            \rmdir($this->dir);
            $this->removed = true;
        }
    }