Load an image.

@param resourceName the name of the image, path must be separated by '/'

@param skipImagesFolder skip imagesFolder prefix addition

@return the image loaded
551050
private Image loadImage(final String resourceName, final boolean skipImagesFolder) {
        Image image = null;

        final List<String> imagePaths = skipImagesFolder ? Collections.singletonList("") : ResourceParameters.IMAGE_FOLDER.get();
        for (int i = 0; i < imagePaths.size() && image == null; i++) {

            String imagePath = imagePaths.get(i);
            if (!imagePath.isEmpty()) {
                imagePath += Resources.PATH_SEP;
            }
            final InputStream imageInputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(imagePath + resourceName);
            if (imageInputStream != null) {
                image = new Image(imageInputStream);
            }
        }
        if (image == null) {
            LOGGER.error("Image : {} not found into base folder: {}", resourceName, ResourceParameters.IMAGE_FOLDER.get());
        }
        return image;
    }
950518
public void setImage(Resource resource)
    {
        ImageIcon image = null;
        if (resource != null && resource.exists())
        {
            try
            {
                image = new ImageIcon(resource.getURL());
            }
            catch (IOException e)
            {
                logger.warn("Error reading resource: " + resource);
                throw new RuntimeException("Error reading resource " + resource, e);
            }
        }
        setImage(image);
    }
996977
public CmsContainerElementData getCachedNewElement(String resourceTypeName) {

        if (m_newElements.containsKey(resourceTypeName)) {
            return m_newElements.get(resourceTypeName);
        }
        return null;
    }
1022798
public static ClassDescriptor createClassDescriptorFromResourceName(String resourceName) {
        if (!isClassResource(resourceName)) {
            throw new IllegalArgumentException("Resource " + resourceName + " is not a class");
        }
        return createClassDescriptor(resourceName.substring(0, resourceName.length() - 6));
    }
837386
private CmsResource readResource(String resourceName) throws CmsException {

        CmsResource resource = null;
        try {
            resource = getCms().readResource(resourceName, CmsResourceFilter.ALL);
        } catch (CmsVfsResourceNotFoundException e) {
            throw new CmsVfsResourceNotFoundException(
                Messages.get().container(
                    Messages.ERR_RESOURCE_DOES_NOT_EXIST_3,
                    resourceName,
                    getCms().getRequestContext().getCurrentProject().getName(),
                    getCms().getRequestContext().getSiteRoot()),
                e);
        }
        return resource;
    }
1136591
public void setResourceContainerImageName(java.util.Collection<StringFilter> resourceContainerImageName) {
        if (resourceContainerImageName == null) {
            this.resourceContainerImageName = null;
            return;
        }

        this.resourceContainerImageName = new java.util.ArrayList<StringFilter>(resourceContainerImageName);
    }
263444
@Override
    public final T addAsResource(String resourceName) throws IllegalArgumentException {
        Validate.notNull(resourceName, "ResourceName should be specified");
        return addAsResource(resourceName, resourceName);
    }
877195
public static Resource create(String name, String imageName, String imageTag) {
    Map<String, String> labels = new LinkedHashMap<String, String>();
    labels.put(NAME_KEY, checkNotNull(name, "name"));
    labels.put(IMAGE_NAME_KEY, checkNotNull(imageName, "imageName"));
    labels.put(IMAGE_TAG_KEY, checkNotNull(imageTag, "imageTag"));
    return Resource.create(TYPE, labels);
  }
393170
protected BufferedImage loadImage (ImageKey key)
    {
//         if (EventQueue.isDispatchThread()) {
//             Log.info("Loading image on AWT thread " + key + ".");
//         }

        BufferedImage image = null;
        try {
            log.debug("Loading image " + key + ".");
            image = key.daprov.loadImage(key.path);
            if (image == null) {
                log.warning("ImageDataProvider.loadImage(" + key + ") returned null.");
            }

        } catch (Exception e) {
            log.warning("Unable to load image '" + key + "'.", e);

            // create a blank image in its stead
            image = createImage(1, 1, Transparency.OPAQUE);
        }

        return image;
    }
33684
public static BufferedImage loadImage(String fileName){
		File f = new File(fileName);
		if(f.exists()){
			return loadImage(f);
		}
		throw new ImageLoaderException(new FileNotFoundException(fileName));
	}
338056
public static String getExtension(String resourceName) {

        String result = null;
        if (!resourceName.endsWith("/")) {
            // folders don't have any extension
            resourceName = CmsResource.getName(resourceName);
            int index = resourceName.lastIndexOf(".") + 1;
            if ((index > 0) && (index < resourceName.length())) {
                result = resourceName.substring(index).toLowerCase();
            }
        }

        return result;
    }
170000
public InputStream getTemporaryResourceAsStream(String resourceName) throws ResourceNotFoundException {
		InputStream is = null;
		if (useFileSystemTempDir) {
			File file = new File(resourceName);
			try {
				is = new FileInputStream(file);
			} catch (FileNotFoundException e) {
				throw new ResourceNotFoundException(resourceName);
			}
		} else {
			is = doGetResourceAsStream(resourceName);
		}

		if (is == null) {
			throw new ResourceNotFoundException(resourceName);
		}

		return is;
	}
1119274
public static URL locateOnClasspath(String resourceName) {
        URL url = null;

        // attempt to load from the context classpath
        ClassLoader loader = Thread.currentThread().getContextClassLoader();
        if (loader != null) {
            url = loader.getResource(resourceName);

            if (url != null) {
                log.debug("Located '{}' in the context classpath", resourceName);
            }
        }

        // attempt to load from the system classpath
        if (url == null) {
            url = ClassLoader.getSystemResource(resourceName);

            if (url != null) {
                log.debug("Located '{}' in the system classpath", resourceName);
            }
        }

        return url;
    }
769397
public function load( $fileName )
    {
        $file = new MFileInfo( $fileName );
        $resource = false;
        $this->type = $file->getSuffix();

        if( $this->type == "png" )
        {
            $resource = imageCreateFromPng( $fileName );
            if( $resource )
            {
                imageAlphaBlending( $resource, true );
                imageSaveAlpha( $resource, true );
            }
        }
        else
        {
            if( $this->type == "gif" )
            {
                $resource = imagecreatefromgif( $fileName );
            }
            else
            {
                if( $this->type == "jpg" || $this->type == "jpeg" )
                {
                    $resource = imagecreatefromjpeg( $fileName );
                }
                else
                {
                    return false;
                }
            }
        }

        if( $resource === false )
        {
            return false;
        }

        $this->resource = $resource;
        $this->fileName = $fileName;
        $this->width = imagesx( $this->resource );
        $this->height = imagesy( $this->resource );

        return true;
    }
794365
public String addMpNewsImage(InputStream inputStream, String fileName) {
        String url = WxEndpoint.get("url.mpnews.image.upload");
        String response = wxClient.post(url, inputStream, fileName);

        Map<String, Object> result = JsonMapper.defaultMapper().json2Map(response);
        if (result.containsKey("url")) {
            return result.get("url").toString();
        } else {
            logger.warn("mpnews image upload failed: {}", response);
            throw new WxRuntimeException(999, response);
        }
    }
1106264
@Override
	public InputStream getResourceAsInputStream(String resourceName) throws IOException {

		try {
			return imgRsHandler.getResourceAsStream(resourceName);
		} catch (ResourceNotFoundException e) {
			throw new IOException("The resource '" + resourceName + "' was not found.");
		}
	}
1107984
public static BufferedImage loadImage(URL url) {
		if( url == null )
			return null;
		try {
			BufferedImage buffered = ImageIO.read(url);
			if( buffered != null )
				return buffered;
			if( url.getProtocol().equals("file")) {
				String path = URLDecoder.decode(url.getPath(), "UTF-8");
				if( !new File(path).exists() ) {
					System.err.println("File does not exist: "+path);
					return null;
				}
			}
		} catch (IOException ignore) {}
		try {
			InputStream stream = url.openStream();
			String path = url.toString();
			if( path.toLowerCase().endsWith("ppm")) {
				return loadPPM(stream,null);
			} else if( path.toLowerCase().endsWith("pgm") ) {
				return loadPGM(stream, null);
			}
			stream.close();
		} catch (IOException ignore) {}

		return null;
	}