gf_images_core

package
v0.0.0-...-a1b0e2b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2024 License: GPL-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GF_EVENT_APP__IMAGE_UPLOAD_INIT     = "GF_EVENT_APP__IMAGE_UPLOAD_INIT"
	GF_EVENT_APP__IMAGE_UPLOAD_COMPLETE = "GF_EVENT_APP__IMAGE_UPLOAD_COMPLETE"
	GF_ENVET_APP__IMAGE_SHARE           = "GF_ENVET_APP__IMAGE_SHARE"
	GF_EVENT_APP__IMAGE_CLASSIFY        = "GF_EVENT_APP__IMAGE_CLASSIFY"
)

Variables

This section is empty.

Functions

func CLIparseArgs

func CLIparseArgs(pLogFun func(string, string)) map[string]interface{}

func CheckImageFormat

func CheckImageFormat(pFormatStr string, pRuntimeSys *gf_core.RuntimeSys) bool

func ConfigGetS3bucketForFlow

func ConfigGetS3bucketForFlow(pFlowNameStr string,
	pConfig *GFconfig) string

func DBmongoImageExists

func DBmongoImageExists(pImageIDstr GFimageID,
	pCtx context.Context,
	pRuntimeSys *gf_core.RuntimeSys) (bool, *gf_core.GFerror)

func DBmongoPutImage

func DBmongoPutImage(pImage *GFimage,
	pCtx context.Context,
	pRuntimeSys *gf_core.RuntimeSys) *gf_core.GFerror

func DownloadFile

func DownloadFile(pImageURLstr string,
	p_local_image_file_path_str string,
	pRuntimeSys *gf_core.RuntimeSys) *gf_core.GFerror

func GetImageDimensionsFromFile

func GetImageDimensionsFromFile(pFile io.Reader,
	pImageExtStr string,
	pRuntimeSys *gf_core.RuntimeSys) (int, int, *gf_core.GFerror)

func GetImageDimensionsFromFilepath

func GetImageDimensionsFromFilepath(pImageLocalFilePathStr string,
	pRuntimeSys *gf_core.RuntimeSys) (int, int, *gf_core.GFerror)

func GetImageDimensionsFromImage

func GetImageDimensionsFromImage(pImg image.Image,
	pRuntimeSys *gf_core.RuntimeSys) (int, int)

func GetImageExtFromURL

func GetImageExtFromURL(pImageURLstr string,
	pRuntimeSys *gf_core.RuntimeSys) (string, *gf_core.GFerror)

func GetImageLargerDimension

func GetImageLargerDimension(pImage image.Image,
	pRuntimeSys *gf_core.RuntimeSys) (int, string)

func GetImageOriginalFilenameFromURL

func GetImageOriginalFilenameFromURL(pImageURLstr string,
	pRuntimeSys *gf_core.RuntimeSys) (string, *gf_core.GFerror)

func GetImageTitleFromURL

func GetImageTitleFromURL(pImageURLstr string,
	pRuntimeSys *gf_core.RuntimeSys) (string, *gf_core.GFerror)

func ImageGetFilepathFromID

func ImageGetFilepathFromID(pImageIDstr GFimageID,
	pImageFormatStr string) string

func ImageGetPublicURL

func ImageGetPublicURL(pImageFilePathStr string,
	pMediaDomainStr string,
	pRuntimeSys *gf_core.RuntimeSys) string

returns the URL of a particular image path, this URL is where the image can be fetched from directly.

func ImageLoadFile

func ImageLoadFile(pImageLocalFilePathStr string,
	pNormalizedExtStr string,
	pRuntimeSys *gf_core.RuntimeSys) (image.Image, *gf_core.GFerror)

func NormalizeImageFormat

func NormalizeImageFormat(pFormatStr string) string

func RunClassify

func RunClassify(pImagesIDsLst []GFimageID,
	pPyDirPathStr string,
	pMetrics *GFmetrics,
	pCtx context.Context,
	pRuntimeSys *gf_core.RuntimeSys) ([]string, *gf_core.GFerror)

func RunPyClassify

func RunPyClassify(pImagesIDsLst []GFimageID,
	pPyDirPathStr string,
	pMetrics *GFmetrics,
	pCtx context.Context,
	pRuntimeSys *gf_core.RuntimeSys) ([]string, *gf_core.GFerror)

func S3getImage

func S3getImage(pImageS3filePathStr string,
	pTargetFileLocalPathStr string,
	pS3bucketNameStr string,
	pS3info *gf_aws.GFs3Info,
	pRuntimeSys *gf_core.RuntimeSys) *gf_core.GFerror

func S3getImageFilepath

func S3getImageFilepath(pImageIDstr GFimageID,
	pImageFormatStr string,
	pRuntimeSys *gf_core.RuntimeSys) string

func S3getImageOriginalFileS3filepath

func S3getImageOriginalFileS3filepath(p_image *GFimage,
	pRuntimeSys *gf_core.RuntimeSys) string

func S3getImageThumbsS3filepaths

func S3getImageThumbsS3filepaths(p_image *GFimage,
	pRuntimeSys *gf_core.RuntimeSys) (string, string, string)

func S3storeImage

func S3storeImage(pImageLocalFilePathStr string,
	pImageThumbs *GFimageThumbs,
	pS3bucketNameStr string,
	pS3info *gf_aws.GFs3Info,
	pRuntimeSys *gf_core.RuntimeSys) *gf_core.GFerror

func S3storeThumbnails

func S3storeThumbnails(pImageThumbs *GFimageThumbs,
	pS3bucketNameStr string,
	pS3info *gf_aws.GFs3Info,
	pRuntimeSys *gf_core.RuntimeSys) *gf_core.GFerror

func SharePipeline

func SharePipeline(pInput *GFshareInput,
	pUserID gf_core.GF_ID,
	pServiceInfo *GFserviceInfo,
	pCtx context.Context,
	pRuntimeSys *gf_core.RuntimeSys) *gf_core.GFerror

func StoreThumbnails

func StoreThumbnails(pImageThumbs *GFimageThumbs,
	pStorage *gf_images_storage.GFimageStorage,
	pRuntimeSys *gf_core.RuntimeSys) *gf_core.GFerror

func ThumbsGetSizeInPx

func ThumbsGetSizeInPx(pThumbSizeInPxInt int,
	pOriginalLargerDimensionInPxInt int,
	pOriginalLargerDimensionNameStr string) (int, int)

func TransformImage

func TransformImage(pImageIDstr GFimageID,
	pImageClientTypeStr string,
	pImagesFlowsNamesLst []string,
	pImageOriginURLstr string,
	pImageOriginPageURLstr string,
	pMetaMap map[string]interface{},
	pImageLocalFilePathStr string,
	pImagesStoreThumbnailsLocalDirPathStr string,
	pPluginsPyDirPathStr string,
	pPluginsMetrics *gf_images_plugins.GFmetrics,
	pUserID gf_core.GF_ID,
	pCtx context.Context,
	pRuntimeSys *gf_core.RuntimeSys) (*GFimage, *GFimageThumbs, *gf_core.GFerror)

pImageOriginPageURLstr - urls of pages (html or some other resource) where the image image_url

was found. this is valid for gf_chrome_ext image sources.
its not relevant for direct image uploads from clients.

func TransformProcessImage

func TransformProcessImage(pImageIDstr GFimageID,
	pImageClientTypeStr string,
	pImagesFlowsNamesLst []string,
	pImageOriginURLstr string,
	pImageOriginPageURLstr string,
	pMetaMap map[string]interface{},
	pNormalizedExtStr string,
	pImageLocalFilePathStr string,
	pImagesStoreThumbnailsLocalDirPathStr string,
	pUserID gf_core.GF_ID,
	pCtx context.Context,
	pRuntimeSys *gf_core.RuntimeSys) (*GFimage, *GFimageThumbs, *gf_core.GFerror)

func TransformProcessImageV2

func TransformProcessImageV2(pImageLocalFilePathStr string,
	pUserID gf_core.GF_ID,
	pCtx context.Context,
	pRuntimeSys *gf_core.RuntimeSys) *gf_core.GFerror

func VerifyImageInfo

func VerifyImageInfo(pImageInfoMap map[string]interface{},
	pRuntimeSys *gf_core.RuntimeSys) (map[string]interface{}, *gf_core.GFerror)

Types

type GF_image_id

type GF_image_id = Gf_image_id

type GFconfig

type GFconfig struct {
	ImagesStoreLocalDirPathStr           string `yaml:"store_local_dir_path"`
	ImagesThumbnailsStoreLocalDirPathStr string `yaml:"thumbnails_store_local_dir_path"`
	VideoStoreLocalDirPathStr            string `yaml:"videos_store_local_dir_path"`

	MediaDomainStr               string `yaml:"media_domain"`
	MainS3bucketNameStr          string `yaml:"main_s3_bucket_name"`
	EmailSharingSenderAddressStr string `yaml:"email_sharing_sender_address"`

	// UPLOADED_IMAGES - this is a special dedicated bucket, separate from buckets for all other flows.
	//                   Mainly because users are pushing data to it directly and so we want to possibly handle
	//                   it in a separate way from other buckets that only have internal GF systems
	//                   uploading data to it.
	Uploaded_images_s3_bucket_str string `yaml:"uploaded_images_s3_bucket"`

	// BOOKMARKS_IMAGES - dedicated bucket for screenshots of bookmarks
	Bookmark_images_s3_bucket_str string `yaml:"bookmark_images_s3_bucket"`

	ImagesFlowToS3bucketDefaultStr string            `yaml:"images_flow_to_s3_bucket_default"`
	ImagesFlowToS3bucketMap        map[string]string `yaml:"images_flow_to_s3_bucket"`

	UseNewStorageEngineBool bool `yaml:"use_new_storage_engine"`

	//------------------------
	// IPFS
	IPFSnodeHostStr string `yaml:"ipfs_node_host"`

	//------------------------
	// PY
	//------------------------
	// PLUGINGS
	PluginsPyDirPathStr string `yaml:"plugins_py_dir_path"`

	// IMAGE_CLASSIFY
	ImagesClassifyPyDirPathStr string `yaml:"images_classify_py_dir_path"`
}

func ConfigGet

func ConfigGet(pConfigPathStr string,
	pUseNewStorageEngineBool bool,
	pIPFSnodeHostStr string,
	pRuntimeSys *gf_core.RuntimeSys) (*GFconfig, *gf_core.GFerror)

type GFimage

type GFimage struct {
	Id                   primitive.ObjectID `json:"-"               bson:"_id,omitempty"`
	IDstr                GFimageID          `json:"id_str"               bson:"id_str"`
	T_str                string             `json:"-"                    bson:"t"` // "img"
	Creation_unix_time_f float64            `json:"creation_unix_time_f" bson:"creation_unix_time_f"`
	UserID               gf_core.GF_ID      `json:"user_id_str"          bson:"user_id_str"`

	//---------------
	ClientTypeStr string   `json:"-"                    bson:"client_type_str"` // "gchrome_ext"|"gf_crawl_images"|"gf_image_editor"
	TitleStr      string   `json:"title_str"            bson:"title_str"`
	FlowsNamesLst []string `json:"flows_names_lst"      bson:"flows_names_lst"` // image can bellong to multiple flows

	//---------------
	/*
		RESOLVED_SOURCE_URL
		IMPORTANT!! - when the image comes from an external url (as oppose to it being
			created internally, or uploaded directly to the system).
			this is different from Origin_page_url_str in that the page_url is the url
			of the page in which the image is found, whereas this origin_url is the url
			of the file on some file server from which the image is served
	*/
	Origin_url_str string `json:"origin_url_str" bson:"origin_url_str"`

	// if the image is extracted from a page, this holds the page_url
	Origin_page_url_str string `json:"origin_page_url_str,omitempty" bson:"origin_page_url_str,omitempty"`

	/*
		DEPRECATED!! - is this used? images are stored in S3, and accessible via URL.
			actual path on the OS filesystem, of the fullsized image gotten from origin_url_str durring
			processing (download/transformation/s3_upload).
	*/
	Original_file_internal_uri_str string `json:"original_file_internal_uri_str,omitempty" bson:"original_file_internal_uri_str,omitempty"`

	ThumbnailSmallURLstr  string `json:"thumbnail_small_url_str"  bson:"thumbnail_small_url_str"`
	ThumbnailMediumURLstr string `json:"thumbnail_medium_url_str" bson:"thumbnail_medium_url_str"`
	ThumbnailLargeURLstr  string `json:"thumbnail_large_url_str"  bson:"thumbnail_large_url_str"`

	//---------------
	Format_str string `json:"format_str" bson:"format_str"` // "jpeg" | "png" | "gif"
	Width_int  int    `json:"width_str"  bson:"width_int"`
	Height_int int    `json:"height_str" bson:"height_int"`

	//---------------
	// COLORS
	DominantColorHexStr string `json:"dominant_color_hex_str" bson:"dominant_color_hex_str"`
	PalleteStr          string `json:"pallete_str"            bson:"pallete_str"`

	//---------------
	// META
	MetaMap map[string]interface{} `json:"meta_map" bson:"meta_map"` // metadata external users might assign to an image
	TagsLst []string               `json:"tags_lst" bson:"tags_lst"` // human facing tags assigned to an image

}

func CreateTestImages

func CreateTestImages(pUserID gf_core.GF_ID,
	pTest *testing.T,
	pCtx context.Context,
	pRuntimeSys *gf_core.RuntimeSys) *GFimage

func DBmongoGetImage

func DBmongoGetImage(pImageIDstr GFimageID,
	pCtx context.Context,
	pRuntimeSys *gf_core.RuntimeSys) (*GFimage, *gf_core.GFerror)

func DBmongoGetRandomImagesRange

func DBmongoGetRandomImagesRange(pImgsNumToGetInt int,
	pMaxRandomCursorPositionInt int,
	pFlowNameStr string,
	pUserID gf_core.GF_ID,
	pRuntimeSys *gf_core.RuntimeSys) ([]*GFimage, *gf_core.GFerror)

func ImageCreateNew

func ImageCreateNew(pImageInfo *GFimageNewInfo,
	pCtx context.Context,
	pRuntimeSys *gf_core.RuntimeSys) (*GFimage, *gf_core.GFerror)

type GFimageExport

type GFimageExport struct {
	Creation_unix_time_f  float64                     `json:"creation_unix_time_f"`
	UserNameStr           gf_identity_core.GFuserName `json:"user_name_str"`
	Title_str             string                      `json:"title_str"`
	Flows_names_lst       []string                    `json:"flows_names_lst"`
	Origin_page_url_str   string                      `json:"origin_page_url_str"`
	ThumbnailSmallURLstr  string                      `json:"thumbnail_small_url_str"`
	ThumbnailMediumURLstr string                      `json:"thumbnail_medium_url_str"`
	ThumbnailLargeURLstr  string                      `json:"thumbnail_large_url_str"`
	Format_str            string                      `json:"format_str"`
	Tags_lst              []string                    `json:"tags_lst"`
}

type GFimageID

type GFimageID = GF_image_id

func CreateIDfromURL

func CreateIDfromURL(pImageURLstr string,
	pRuntimeSys *gf_core.RuntimeSys) (GFimageID, *gf_core.GFerror)

func CreateImageFilePathFromURL

func CreateImageFilePathFromURL(pImageIDstr GFimageID,
	pImageURLstr string,
	pImagesStoreLocalDirPathStr string,
	pRuntimeSys *gf_core.RuntimeSys) (string, GFimageID, *gf_core.GFerror)

func CreateImageID

func CreateImageID(pImageURIstr string,
	pRuntimeSys *gf_core.RuntimeSys) GFimageID

func FetcherGetExternImage

func FetcherGetExternImage(pImageURLstr string,
	pImagesStoreLocalDirPathStr string,
	pRandomTimeDelayBool bool,
	pRuntimeSys *gf_core.RuntimeSys) (string, GFimageID, *gf_core.GFerror)

type GFimageNewInfo

type GFimageNewInfo struct {
	IDstr                          GFimageID
	Title_str                      string
	Flows_names_lst                []string
	Image_client_type_str          string
	Origin_url_str                 string
	Origin_page_url_str            string
	Original_file_internal_uri_str string
	ThumbnailSmallURLstr           string
	ThumbnailMediumURLstr          string
	ThumbnailLargeURLstr           string
	Format_str                     string
	Width_int                      int
	Height_int                     int

	Meta_map map[string]interface{}

	// user that owns this image, that uploaded or added it in some other way
	UserID gf_core.GF_ID
}

type GFimageThumbs

type GFimageThumbs struct {
	Small_relative_url_str  string `json:"small_relative_url_str"`
	Medium_relative_url_str string `json:"medium_relative_url_str"`
	Large_relative_url_str  string `json:"large_relative_url_str"`

	Small_local_file_path_str  string
	Medium_local_file_path_str string
	Large_local_file_path_str  string
}

func CreateThumbnails

func CreateThumbnails(pImage image.Image,
	pImageIDstr GFimageID,
	pImageFormatStr string,
	pTargetThumbnailsLocalDirPathStr string,
	pSmallThumbSizePxInt int,
	pMediumThumbSizePxInt int,
	pLargeThumbSizePxInt int,
	pRuntimeSys *gf_core.RuntimeSys) (*GFimageThumbs, *gf_core.GFerror)

type GFmetrics

type GFmetrics struct {

	// IMAGE_UPLOAD
	ImageUploadClientDurationGauge         prometheus.Gauge
	ImageUploadClientTransferDurationGauge prometheus.Gauge

	// IMAGE_CLASSIFY
	ImageClassifyPyExecDurationGauge prometheus.Gauge
}

func MetricsCreate

func MetricsCreate(pNamespaceStr string) *GFmetrics

type GFserviceInfo

type GFserviceInfo struct {
	Port_str      string
	DomainBaseStr string

	// DB
	Mongodb_host_str    string
	Mongodb_db_name_str string

	ImagesStoreLocalDirPathStr           string
	ImagesThumbnailsStoreLocalDirPathStr string
	VideoStoreLocalDirPathStr            string

	MediaDomainStr            string
	ImagesMainS3bucketNameStr string
	TemplatesPathsMap         map[string]string
	ConfigFilePathStr         string

	// email address from which image sharing emails are sent
	EmailSharingSenderAddressStr string

	//------------------------
	// AUTH_SUBSYSTEM_TYPE
	AuthSubsystemTypeStr string

	// AUTH_LOGIN_URL - url of the login page to which the system should
	//                  redirect users when email is confirmed.
	AuthLoginURLstr string
	KeyServer       *gf_identity_core.GFkeyServerInfo

	// NEW_STORAGE_ENGINE - flag indicating if the new image storage engine should be used
	UseNewStorageEngineBool bool

	// IPFS_NODE_HOST - host/gateway to use to connect to for IPFS operations
	IPFSnodeHostStr string

	// EVENTS_APP - enable sending of app events from various functions
	EnableEventsAppBool bool
}

type GFshareInput

type GFshareInput struct {
	ImageID         GFimageID
	EmailAddressStr string
	EmailSubjectStr string
	EmailBodyStr    string
}

type Gf_image_id

type Gf_image_id string // DEPRECATED!! - switch to using GF_image_id fully

type ImageFetchError

type ImageFetchError struct {
	Id                   primitive.ObjectID `json:"-"                    bson:"_id,omitempty"`
	Id_str               string             `json:"id_str"               bson:"id_str"`
	T_str                string             `json:"-"                    bson:"t"` // img_fetch_error
	Creation_unix_time_f float64            `json:"creation_unix_time_f" bson:"creation_unix_time_f"`
	Image_url_str        string             `json:"image_url_str"        bson:"image_url_str"`
	Status_code_int      int                `json:"status_code_int"      bson:"status_code_int"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL